www.digitalmars.com         C & C++   DMDScript  

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


          Issue ID: 20845
           Summary: output better error message regarding the cas data
           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
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:
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:
/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
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 2020