https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
Bug ID: 95250 Summary: [D] ICE instead of error when trying to use bad template type inside template Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: witold.baryluk+gcc at gmail dot com Target Milestone: --- 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) $