Bug 21723 – Linker error: two module static library, main compiled inline, invariant that defines a function, type alias, and an alias lambda

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-03-16T08:01:34Z
Last change time
2022-07-09T16:31:53Z
Keywords
industry, pull
Assigned to
No Owner
Creator
FeepingCreature

Comments

Comment #0 by default_357-line — 2021-03-16T08:01:34Z
Sorry for the random list of keywords in the summary but this one is pretty opaque. Take two modules: a.d: import b; alias Struct = b.Struct; b.d: struct Struct { invariant { void call() { } } void templfun()() { } } main.d: import a; void trigger(Instance val) { val.templfun; } void main() { alias lambda = a => a; } Build as such: dmd a.d b.d -lib -oflibrary.a dmd -inline main.d ./library.a Behold the linker error. /usr/bin/ld: main.o: in function `pure nothrow @nogc @safe void b.Struct.templfun!().templfun()': main.d:(.text.pure nothrow @nogc @safe void b.Struct.templfun!().templfun()[pure nothrow @nogc @safe void b.Struct.templfun!().templfun()]+0xd): undefined reference to `const void b.Struct.__invariant3()' /usr/bin/ld: main.d:(.text.pure nothrow @nogc @safe void b.Struct.templfun!().templfun()[pure nothrow @nogc @safe void b.Struct.templfun!().templfun()]+0x19): undefined reference to `const void b.Struct.__invariant3()' collect2: error: ld returned 1 exit status Might be another case of #14429 ?
Comment #1 by default_357-line — 2021-03-16T08:08:06Z
Ah correction, that should of course be void trigger(Struct val) in main.d. Copypaste fail.
Comment #2 by dlang-bot — 2022-05-30T10:41:17Z
@FeepingCreature updated dlang/dmd pull request #14176 "Fix issue 23148: Generate invariant id on the basis of location rather than counter." fixing this issue: - Fix issue 23148, 21723: Generate invariant id on the basis of location rather than counter. This makes __invariant more resilient to template order issues. https://github.com/dlang/dmd/pull/14176
Comment #3 by dlang-bot — 2022-05-30T11:54:31Z
dlang/dmd pull request #14176 "Fix issue 23148, 21723: Generate invariant id on the basis of location rather than counter." was merged into stable: - 4e01c6a4dc5ec971dc29cae6c0208b6888e147d6 by Mathis Beer: Fix issue 23148, 21723: Generate invariant id on the basis of location rather than counter. This makes __invariant more resilient to template order issues. https://github.com/dlang/dmd/pull/14176
Comment #4 by dlang-bot — 2022-07-09T16:31:53Z
dlang/dmd pull request #14280 "merge stable" was merged into master: - 5c41c29b085f7a55a2d20381565c8d1d25b92c2b by Mathis Beer: Fix issue 23148, 21723: Generate invariant id on the basis of location rather than counter. This makes __invariant more resilient to template order issues. https://github.com/dlang/dmd/pull/14280