www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20629] New: atomicStore does not compile for struct using -m64

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

          Issue ID: 20629
           Summary: atomicStore does not compile for struct using -m64
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

The following code fails to compile with -m64 but passes with -m32:

atomics.d:
-------------------------------------
import core.atomic : atomicStore;

void main()
{
    static struct Struct
    {
        uint a, b;
    }
    shared Struct s1 = Struct(1, 2);
    atomicStore(s1, Struct(3, 4));
    assert(cast(uint) s1.a == 3);
    assert(cast(uint) s1.b == 4);
}
-------------------------------------

Compiler output:
-------------------------------------
core\internal\atomic.d(231): Error: template
core.internal.atomic.atomicExchange cannot deduce function from argument types
!(cast(MemoryOrder)5, false)(Struct*, Struct), candidates are:
core\internal\atomic.d(289):        atomicExchange(MemoryOrder order =
MemoryOrder.seq, bool result = true, T)(T* dest, T value)
  with order = order,
       result = false,
       T = Struct
  must satisfy one of the following constraints:
       is(T : ulong)
       is(T == class)
       is(T == interface)
       is(T U : U*)
core\atomic.d(127): Error: template instance
core.internal.atomic.atomicStore!(cast(MemoryOrder)5, Struct) error
instantiating
core\atomic.d(142):        instantiated from here:
atomicStore!(cast(MemoryOrder)5, Struct, Struct)
.\atomics.d(12):        instantiated from here:
atomicStore!(cast(MemoryOrder)5, Struct, Struct)
-------------------------------------

Reduced from https://forum.dlang.org/post/hyapjxbgluhnqeipgozp forum.dlang.org.

--
Mar 03