https://issues.dlang.org/show_bug.cgi?id=15318
Martin Nowak <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Martin Nowak <[email protected]> --- This seems to be a case where the second rule of this issue 14431 fix doesn't work. http://forum.dlang.org/post/[email protected] > 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). --
