https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250

--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Witold Baryluk from comment #0)
> https://godbolt.org/z/xWrXP5
> 
> Minimized version
> 
> ```
> module m;
> 
> import std.traits : Unsigned;
> 
> void* f(T)(T a, T b) {
>         alias UnsignedVoid = Unsigned!(T);
>         return cast(T)(cast(T)(cast(UnsignedVoid)(a-b) / 2));
> }
> //static assert(is(typeof(f(null, null)) == void*));   // ICE
> static assert(is(typeof(f!(void*)(null, null)) == void*));  // ICE
> ```
> 
> The code is not correct, but on DMD v2.092.0 and LDC 1.20.1 (LLVM 9.0.1) it
> does say static assert is false (which is also incorrect), and doesn't crash.
> 
> Instead it should say, something like this:
> 
> /usr/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/traits.d:7163:13: error:
> static assert  "Type void* does not have an Unsigned counterpart"
> 

Because the error occurs in a speculative context (is-expression), the error
from Unsigned!() is gagged.  The user should only see the static assert is
false message.

To see speculative errors, compile with -Wspeculative.

Reply via email to