https://issues.dlang.org/show_bug.cgi?id=13394
Kenji Hara <k.hara...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |link-failure Hardware|x86 |All OS|Mac OS X |All --- Comment #1 from Kenji Hara <k.hara...@gmail.com> --- Introduced in: https://github.com/D-Programming-Language/dmd/pull/3775 ==== When a.d is compiled, compiler instantiates Btpl!A and outputs its invariant objcode to a.obj. Next b.d is compiled, the `new B` expression instantiates the Btpl!A template constructor. It implicitly calls the invariant in post-condition, bug Btpl!A is explicitly instantiated in the non-root module (== a module which not directly compiled from command line) a. So compiler assumes that the Btpl!A.invariant objcode will be provided in linking phase and skips its codegen. However, currently dmd always adds the inferred function attributes into the symbol name of instantiated functions. Therefore, dmd a.d will emit the objcode of Btpl!A.invariant with the symbol name: _D1a15__T4BtplTC1a1AZ4Btpl11__invariantMxFNaNbNiNfZv But dmd b.d does not invoke semantic3 of Btpl!A.invariant. Then b.obj refer the invariant by using the symbol name: _D1a15__T4BtplTC1a1AZ4Btpl11__invariantMxFZv <-- does not contain the inferred attributes NaNbNiNf Then link-failure happens. --