www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20845] New: output better error message regarding the cas

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

          Issue ID: 20845
           Summary: output better error message regarding the cas data
                    size
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mingwu gmail.com

--------------------------------------------------------------------------------
$ cat c.d
import std.stdio;
import core.atomic;

struct N {
  N* prev;
  N* curr;
  N* next;
}

align(16) shared(N) n;

void main() {
  writeln(size_t.sizeof*2, N.sizeof);
  cas(&n, n, n);
}

$ ldc2  -c c.d
/home/zhou/project/ldc2-1.20.0-linux-x86_64/bin/../import/core/internal/atomic.d(122):
Error: static assert:  "Cannot atomically load/store type of size 24LU"





$ dmd -c c.d
/usr/include/dmd/druntime/import/core/atomic.d(293): Error: template
core.internal.atomic.atomicCompareExchangeStrongNoResult cannot deduce function
from argument types !(cast(MemoryOrder)5, cast(MemoryOrder)5)(N*, N, N),
candidates are:
/usr/include/dmd/druntime/import/core/internal/atomic.d(481):       
atomicCompareExchangeStrongNoResult(MemoryOrder succ = MemoryOrder.seq,
MemoryOrder fail = MemoryOrder.seq, T)(T* dest, const T compare, T value)
  with succ = succ,
       fail = fail,
       T = N
  must satisfy the following constraint:
       CanCAS!T
/usr/include/dmd/druntime/import/core/atomic.d(313): Error: template instance
core.atomic.cas!(cast(MemoryOrder)5, cast(MemoryOrder)5, N, N, N) error
instantiating
c.d(14):        instantiated from here: cas!(cast(MemoryOrder)5,
cast(MemoryOrder)5, N, shared(N), shared(N))



$ uname -a

x86_64 x86_64 x86_64 GNU/Linux


$ dmd --version
DMD64 D Compiler v2.092.0
Copyright (C) 1999-2020 by The D Language Foundation, All Rights Reserved
written by Walter Bright
--------------------------------------------------------------------------------

--
May 19