[Issue 20845] New: output better error message regarding the cas data size

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 19 16:23:28 UTC 2020


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 at puremagic.com
          Reporter: mingwu at 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"

# This error is very clear what's going wrong, i.e. the data size is wrong
#
# now let's see DMD's error message:

$ 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))

# The programmer has no idea what's going wrong.

$ uname -a
Linux titan 4.15.0-99-generic #100-Ubuntu SMP Wed Apr 22 20:32:56 UTC 2020
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
--------------------------------------------------------------------------------

--


More information about the Digitalmars-d-bugs mailing list