Compiling the example below with "gdc example.d some_class.d" works. When compiling with "gdc -O example.d some_class.d" I get a linker error: /tmp/ccmXtlCq.o: In function `_DT24_D10some_class1B3fooMFHAyaAyaZv': example.d:(.text._DT24_D10some_class1B3fooMFHAyaAyaZv[_DT24_D10some_class1B3fooMFHAyaAyaZv]+0x17): undefined reference to `_D10some_class1B3fooMFHAyaAyaZ12__dgliteral2MFNaNbNiNfZAya' collect2: error: ld returned 1 exit status Here are the two files. I wasn't able to reduce them further, although I think it should be possible... example.d: import some_class; void main() { } interface A { abstract void foo(string[string] a); } interface C:A { } class D:B,C { } some_class.d: import std.conv; import example; class B:A { override void foo(string[string] a) { if (to!int(a.get("b","1"))!=1) return; } }
Confirmed. (NB: _DT is a thunk)
Reduced test: --- import some_class; interface A { void foo(int[int]); } interface C:A { } class D:B,C { } --- import example; class ConvException : Exception { this(string s) { super(s); } } T to(T, A)(A) { throw new ConvException(null); } class B : A { void foo(int[int] a) { if (to!int(a.get(0, 1))) return; } } --- Happens because the thunk generated in 'example.d' inlines the function call to 'B.foo'. However that doesn't work because it calls a lambda that is not externally visible outside of the compilation unit of 'some_class.d'.
https://github.com/D-Programming-GDC/GDC/pull/409