As of DMD 2.097.2, compiling the following program with the flag `-checkaction=context` results in a linker error. --- import std; void main() { assert(0); } --- The error is: --- /usr/bin/ld: bug.o: in function `_Dmain': bug.d:(.text._Dmain[_Dmain]+0x33): undefined reference to `_D4core8internal7dassert__T14_d_assert_failTiZQtFNaNbNiNfMxAyaxiZAya' collect2: error: ld returned 1 exit status Error: linker exited with status 1 --- Demangled: --- /usr/bin/ld: bug.o: in function `_Dmain': bug.d:(.text._Dmain[_Dmain]+0x33): undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), const(int))' collect2: error: ld returned 1 exit status Error: linker exited with status 1 --- Removing the line `import std;`, or changing it to import a different module such as `std.range`, causes the program to compile and link successfully. According to run.dlang.io, this is a regression introduced in DMD 2.093.
Just ran into this one. So sad it's been broken for a year. I don't recall what was the reason this option is enabled via the -checkaction=context switch? Is it to avoid additional memory allocations?
I've just encountered this as well. Still fails on DMD 2.101.1 with the same missing symbol, but when combined with -allinst, it fails in a subtly different way: ``` /dlang/dmd/linux/bin64/../../src/phobos/std/variant.d:941: error: undefined reference to '_D4core8internal7dassert__T14_d_assert_failTbZQtFNaNbNiNfMxAyaxbZAya' ``` This one is a `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(bool)._d_assert_fail(scope const(immutable(char)[]), const(bool))`
(In reply to Paul Backus from comment #0) > As of DMD 2.097.2, compiling the following program with the flag > `-checkaction=context` results in a linker error. > > --- > import std; > > void main() > { > assert(0); > } > --- > WORKSFORME $ dmd --version DMD64 D Compiler v2.109.1 Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved written by Walter Bright $ cat asszer.d import std; void main() { assert(0); } $ dmd asszer.d $ ./asszer core.exception.AssertError@asszer.d(5): Assertion failure ---------------- ??:? _d_assertp [0x4bbf14] ??:? _Dmain [0x4b30e0]
Correction: WORKSFORME $ dmd -checkaction=context asszer.d $ ./asszer core.exception.AssertError@asszer.d(5): Assertion failure ---------------- ??:? _d_assertp [0x4bbf14] ??:? _Dmain [0x4b30e0]