Bug 20845 – output better error message regarding the cas data size

Status
NEW
Severity
enhancement
Priority
P4
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-05-19T16:23:28Z
Last change time
2024-12-07T13:40:14Z
Assigned to
No Owner
Creator
mw
Moved to GitHub: dmd#17403 →

Comments

Comment #0 by mingwu — 2020-05-19T16:23:28Z
-------------------------------------------------------------------------------- $ 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 --------------------------------------------------------------------------------
Comment #1 by robert.schadek — 2024-12-07T13:40:14Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17403 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB