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" 7163 | static assert(false, "Type " ~ T.stringof ~ | ^ Here is a local run, on Linux, amd64. $ gdc gdc_ice.d d21: internal compiler error: Segmentation fault 0xbd63ef crash_signal ../../src/gcc/toplev.c:328 0x7f31b746c7ff ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0x71ed1e isAggregate(Type*) ../../src/gcc/d/dmd/opover.c:161 0x71ed1e visit ../../src/gcc/d/dmd/opover.c:586 0x71e935 op_overload(Expression*, Scope*) ../../src/gcc/d/dmd/opover.c:1385 0x6d0b88 Expression::op_overload(Scope*) ../../src/gcc/d/dmd/expression.h:213 0x6d0b88 ExpressionSemanticVisitor::visit(DivExp*) ../../src/gcc/d/dmd/expressionsem.c:6891 0x6cd7b4 semantic(Expression*, Scope*) ../../src/gcc/d/dmd/expressionsem.c:8214 0x6cd7b4 unaSemantic(UnaExp*, Scope*) ../../src/gcc/d/dmd/expressionsem.c:8164 0x6cd7b4 ExpressionSemanticVisitor::visit(CastExp*) ../../src/gcc/d/dmd/expressionsem.c:4203 0x6cd7b4 semantic(Expression*, Scope*) ../../src/gcc/d/dmd/expressionsem.c:8214 0x6cd7b4 unaSemantic(UnaExp*, Scope*) ../../src/gcc/d/dmd/expressionsem.c:8164 0x6cd7b4 ExpressionSemanticVisitor::visit(CastExp*) ../../src/gcc/d/dmd/expressionsem.c:4203 0x6c5a45 semantic(Expression*, Scope*) ../../src/gcc/d/dmd/expressionsem.c:8214 0x74795f StatementSemanticVisitor::visit(ReturnStatement*) ../../src/gcc/d/dmd/statementsem.c:2757 0x74a949 semantic(Statement*, Scope*) ../../src/gcc/d/dmd/statementsem.c:3782 0x74a949 StatementSemanticVisitor::visit(CompoundStatement*) ../../src/gcc/d/dmd/statementsem.c:142 0x743755 semantic(Statement*, Scope*) ../../src/gcc/d/dmd/statementsem.c:3782 0x6e8ba9 FuncDeclaration::semantic3(Scope*) ../../src/gcc/d/dmd/func.c:1711 0x6e8ba9 FuncDeclaration::semantic3(Scope*) ../../src/gcc/d/dmd/func.c:1354 $ $ gdc -v Using built-in specs. COLLECT_GCC=gdc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 10.1.0-1' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,amdgcn-amdhsa,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.1.0 (Debian 10.1.0-1) $
(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.
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>: https://gcc.gnu.org/g:1d19c9cd3dd99ba8885c0fc93223918399f73939 commit r11-1661-g1d19c9cd3dd99ba8885c0fc93223918399f73939 Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Tue Jun 23 22:43:27 2020 +0200 d: Merge upstream dmd 90450f3ef. Fixes a regression caused by an incomplete backport of converting the Expression semantic pass to a Visitor. Reviewed-on: https://github.com/dlang/dmd/pull/11314 gcc/d/ChangeLog: PR d/95250 * dmd/MERGE: Merge upstream dmd 90450f3ef. gcc/testsuite/ChangeLog: PR d/95250 * gdc.dg/pr95250.d: New test.
The releases/gcc-10 branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>: https://gcc.gnu.org/g:95f5dc7f70b09def9f2002f5cbef986b21d456e3 commit r10-8373-g95f5dc7f70b09def9f2002f5cbef986b21d456e3 Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Tue Jun 23 22:43:27 2020 +0200 d: Fix ICE during error recovery in semantic pass Fixes a regression caused by an incomplete backport of converting the Expression semantic pass to a Visitor. gcc/d/ChangeLog: PR d/95250 * dmd/expressionsem.c (class ExpressionSemanticVisitor): Return early if error occurred during semantic of DivExp. gcc/testsuite/ChangeLog: PR d/95250 * gdc.dg/pr95250.d: New test. (cherry picked from commit 1d19c9cd3dd99ba8885c0fc93223918399f73939)
The releases/gcc-9 branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>: https://gcc.gnu.org/g:57096f5c52be8c5f0c29663234f31845bb172216 commit r9-8701-g57096f5c52be8c5f0c29663234f31845bb172216 Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Tue Jun 23 22:43:27 2020 +0200 d: Fix ICE during error recovery in semantic pass Fixes a regression caused by an incomplete backport of converting the Expression semantic pass to a Visitor. gcc/d/ChangeLog: PR d/95250 * dmd/expressionsem.c (class ExpressionSemanticVisitor): Return early if error occurred during semantic of DivExp. gcc/testsuite/ChangeLog: PR d/95250 * gdc.dg/pr95250.d: New test. (cherry picked from commit 1d19c9cd3dd99ba8885c0fc93223918399f73939)
Done