[Issue 15318] Templates not emitted for two "partial cycles"
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Nov 11 18:11:04 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15318
Martin Nowak <code at dawg.eu> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |code at dawg.eu
--- Comment #1 from Martin Nowak <code at dawg.eu> ---
This seems to be a case where the second rule of this issue 14431 fix doesn't
work.
http://forum.dlang.org/post/mailman.697.1440962414.13986.digitalmars-d-bugs@puremagic.com
> If a template is instantiated in non-root module, compiler usually does not have to put it in object file. But if a template is instantiated in both of root and non-root modules which mutually import each other, it needs to placed in objfile.
===
In both of the compilations there is a root and a non-root module instantiating
bar!5. Now unfortunately the compiler decides both times that the non-root
module should do it.
This problem would be solved by my proposal to define a global order for who is
responsible to instantiate a template, by choosing the module with the
lexicographically smaller module name.
https://github.com/D-Programming-Language/dmd/pull/4384#discussion_r29910422
https://issues.dlang.org/show_bug.cgi?id=14431#c12
This would establish a stable order between B and C, and no matter how you
compile them, B gets to instantiate the template.
===
An intermediate workaround for your problem is to use the -allinst switch, even
though it slows down compilation a lot. You can also compile each module
separately in which case both B and C get the instance (in general this is even
slower than -allinst).
--
More information about the Digitalmars-d-bugs
mailing list