Issue 22902 - dmd 2.099 regression: unittest -checkaction=context and import std.regex causes link error
Summary: dmd 2.099 regression: unittest -checkaction=context and import std.regex caus...
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-18 20:00 UTC by kdevel
Modified: 2023-01-10 17:59 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kdevel 2022-03-18 20:00:05 UTC
Maybe related to Issue#22374 and Issue#19937

Taken from forum post [1]

zstack.d:
---
module zstack;
import std.stdio: writeln;

void bar (int [] i)
{
   writeln ("i: ", i);
}

unittest {
   int [] arr;
   bar (arr);
}
---

zrepo.d:
---
module parser;
import std.regex;
import zstack;
---

   $ dmd -g -i -unittest -checkaction=context -main -run zrepro 2>&1 | ddemangle

gives

zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), const(int))':
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:41: undefined reference to `pure nothrow @nogc @safe bool core.internal.dassert.inFinalizer!().inFinalizer()'
zrepro.o: In function `pure nothrow @nogc @safe uint std.uni.sliceBits!(0uL, 8uL).sliceBits.opCall!(dchar).opCall(dchar)':
[...]/dmd2/linux/bin64/../../src/phobos/std/uni/package.d:5593: undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(const(uint))._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), ref const(uint), const(int))'
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(bool)._d_assert_fail(scope const(immutable(char)[]), ref const(bool))':
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:41: undefined reference to `pure nothrow @nogc @safe bool core.internal.dassert.inFinalizer!().inFinalizer()'
zrepro.o: In function `pure nothrow @nogc @safe uint std.uni.sliceBits!(13uL, 21uL).sliceBits.opCall!(dchar).opCall(dchar)':
[...]/dmd2/linux/bin64/../../src/phobos/std/uni/package.d:5593: undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(const(uint))._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), ref const(uint), const(int))'
zrepro.o: In function `pure nothrow @nogc @safe uint std.uni.sliceBits!(8uL, 13uL).sliceBits.opCall!(dchar).opCall(dchar)':
[...]/dmd2/linux/bin64/../../src/phobos/std/uni/package.d:5593: undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(const(uint))._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), ref const(uint), const(int))'
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(ulong)._d_assert_fail!(ulong)._d_assert_fail(scope const(immutable(char)[]), ref const(ulong), const(ulong))':
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:70: undefined reference to `pure nothrow @nogc @safe bool core.internal.dassert.inFinalizer!().inFinalizer()'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:75: undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref const(ulong))'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:77: undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref const(ulong))'
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(ulong)._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), ref const(ulong), const(int))':
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:70: undefined reference to `pure nothrow @nogc @safe bool core.internal.dassert.inFinalizer!().inFinalizer()'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:75: undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref const(ulong))'
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert._d_assert_fail!(ulong)._d_assert_fail!(ulong)._d_assert_fail(scope const(immutable(char)[]), ref const(ulong), ref const(ulong))':
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:70: undefined reference to `pure nothrow @nogc @safe bool core.internal.dassert.inFinalizer!().inFinalizer()'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:75: undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref const(ulong))'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:77: undefined reference to `pure nothrow @nogc @safe immutable(char)[] core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref const(ulong))'
collect2: ld returned 1 exit status
Error: linker exited with status 1

If import std.regex; is commented out or if -checkaction=context is removed from the cmd line the unittest passes.

[1] https://forum.dlang.org/thread/aabnjercvkywppgntttc@forum.dlang.org
Comment 1 kdevel 2022-05-28 23:04:25 UTC
>    $ dmd -g -i -unittest -checkaction=context -main -run zrepro 2>&1 |
                                                               ^ (typo)
> ddemangle
> 
> gives
> 
> zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[]
> core.internal.dassert._d_assert_fail!(int)._d_assert_fail(scope
> [...]

Seems to be template generation related

$ dmd -allinst -g -i -unittest -checkaction=context -main -run zrepo 2>&1 | ddemangle
1 modules passed unittests