digitalmars.D.bugs - [Issue 23148] New: Missing invariant symbol with static library when
- d-bugmail puremagic.com (54/54) May 30 2022 https://issues.dlang.org/show_bug.cgi?id=23148
https://issues.dlang.org/show_bug.cgi?id=23148 Issue ID: 23148 Summary: Missing invariant symbol with static library when template function declares struct with destructor and invariant that instantiates template with lambda, also main has a lambda Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: default_357-line yahoo.de What an odyssey! a.d: struct Struct { SumType!() v1; } void foo()() { SumType!() v2; } struct SumType() { ~this() { } invariant { alias a = {}; match!a(); } } void match(alias handler)() { } b.d: import a; alias l = _ => 0; void main() { foo!()(); } Repro: dmd a.d -of=liba.a -lib dmd b.d -L-L. -L-la b.d:(.text._D1a__T7SumTypeZQj12__invariant4MxFNaNbNiNfZv[_D1a__T7SumTypeZQj12__invariant4MxFNaNbNiNfZv]+0x5): undefined reference to `_D1a__T5matchS_DQo__T7SumTypeZQj12__invariant4MxFZ9__lambda1FNaNbNiNfZvZQCnQp' This regression was introduced with https://github.com/dlang/dmd/commit/2acf5570964ef1eaa403b602b86d41cac5567655 The relevant snippet is the assignment of instantiating module in dtemplate.d:6296. If the check for tinst/tinst.minst is removed, so that the block for tnext runs, as it did before the commit, the error disappears. The linker error seems to come down to a disagreement between dmd a.d and dmd b.d on what the name of the generated invariant in SumType should be. In the failing case, there is an undefined reference to invariant4 in b.o, but a definition of invariant3 in a.o. This bug report seems similar to https://issues.dlang.org/show_bug.cgi?id=21723 , but it's different enough in detail that I decided to file a separate pr On suggestion of opDispatch in #d, I tried changing __invariant name generation to use line number rather than idCounter for suffix. With that, the linker error disappeared. --
May 30 2022