www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20359] New: core.atomic.cas throws with null as `ifThis`

https://issues.dlang.org/show_bug.cgi?id=20359

          Issue ID: 20359
           Summary: core.atomic.cas throws with null as `ifThis`
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: johnch_atms hotmail.com

The following code produces an access violation in the 2.089.0 release:

import core.atomic;
void main() {
  Object a, b = new Object;
  cas(&a, null, b);
}

If you cast everything to shared - cas(cast(shared)&a, cast(shared)null,
cast(shared)b) - it works as expected. Also if you pass an instantiated object
to the `ifThis` argument, it will also work correctly.

--
Nov 05 2019