this triggers a dmd assert:
---
alias noreturn = typeof(*null);
template T(A)
{
A a;
}
void main()
{
alias Tnr = T!noreturn;
}
---
output:
---
ERROR: This is a compiler bug.
Please report it via https://issues.dlang.org/enter_bug.cgi
with, preferably, a reduced, reproducible example and the information below.
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.
---
DMD v2.097.0-beta.1-42-g9d718f2f8
predefs single_module runnable_module run_single_module DigitalMars LittleEndian D_Version2 all D_SIMD Posix ELFv1 linux CRuntime_Glibc CppRuntime_Gcc D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary /home/basile/dev/repos/dlang/dmd/generated/linux/release/64/dmd
version v2.097.0-beta.1-42-g9d718f2f8
config /home/basile/dev/repos/dlang/dmd/generated/linux/release/64/dmd.conf
DFLAGS -I/home/basile/dev/repos/dlang/dmd/generated/linux/release/64/../../../../../druntime/import -I/home/basile/dev/repos/dlang/dmd/generated/linux/release/64/../../../../../phobos -L-L/home/basile/dev/repos/dlang/dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64 -L--export-dynamic -fPIC
---
core.exception.AssertError@src/dmd/toobj.d(603): Assertion failure
----------------
??:? _d_assertp [0x8e5b55]
src/dmd/toobj.d:603 _ZN9toObjFile9ToObjFile5visitEP14VarDeclaration [0x7e71e8]
src/dmd/declaration.d:1642 _ZN14VarDeclaration6acceptEP7Visitor [0x618fe5]
src/dmd/toobj.d:848 void dmd.toobj.toObjFile(dmd.dsymbol.Dsymbol, bool).ToObjFile.visit(dmd.dtemplate.TemplateInstance).__lambda2!(dmd.dsymbol.Dsymbol).__lambda2(dmd.dsymbol.Dsymbol) [0x7e7a89]
src/dmd/dsymbol.d:103 void dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*, void delegate(dmd.dsymbol.Dsymbol)) [0x6541a7]
src/dmd/toobj.d:848 _ZN9toObjFile9ToObjFile5visitEP16TemplateInstance [0x7e7a64]
src/dmd/dtemplate.d:7504 _ZN16TemplateInstance6acceptEP7Visitor [0x68291d]
src/dmd/toobj.d:1029 _Z9toObjFileP7Dsymbolb [0x7e6786]
src/dmd/glue.d:429 _Z10genObjFileP6Moduleb [0x7d02d1]
src/dmd/mars.d:627 int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0x5c8073]
src/dmd/mars.d:1070 _Dmain [0x5c9869]
Comment #1 by moonlightsentinel — 2021-10-12T20:11:25Z
The assertion failure is caused by the TLS variable and reproducible without a template:
=============================
noreturn tlsNoreturn;
============================
Comment #2 by dlang-bot — 2021-10-12T20:18:44Z
@MoonlightSentinel created dlang/dmd pull request #13163 "Fix 21952 - Don't assert for global / tls variables of type noreturn" fixing this issue:
- Fix 21952 - Don't assert for global / tls variables of type noreturn
The old code assumed variables of size 0 must be static arrays `T[0]`
but `noreturn.sizeof` is 0.
https://github.com/dlang/dmd/pull/13163
Comment #3 by dlang-bot — 2021-10-12T21:38:17Z
dlang/dmd pull request #13163 "Fix 21952 - Don't assert for global / tls variables of type noreturn" was merged into stable:
- e5c0d2141caf147d1df644f16a1c8766ce0208e3 by MoonlightSentinel:
Fix 21952 - Don't assert for global / tls variables of type noreturn
The old code assumed variables of size 0 must be static arrays `T[0]`
but `noreturn.sizeof` is 0.
https://github.com/dlang/dmd/pull/13163
Comment #4 by dlang-bot — 2021-10-13T13:17:27Z
dlang/dmd pull request #13164 "Merge stable" was merged into master:
- b2555a70cb87da257c46a1f6a017857c78ffdac3 by MoonlightSentinel:
Fix 21952 - Don't assert for global / tls variables of type noreturn
The old code assumed variables of size 0 must be static arrays `T[0]`
but `noreturn.sizeof` is 0.
https://github.com/dlang/dmd/pull/13164