This bug forces link of any module that indirectly imports any module with unittest (nearly ANY module) even when I compile without -unittest switch. It forced me to link in a module working with registry, thus forcing dependency on extra library advapi32.dll even when I didn't use anything from that module, this just killed me. I'm not sure whether this is one bug or two, but together they are fearful. test.d --- import test2; int main() { return 0; } --- test2.d --- module test2; import test3; --- test3.d --- module test3; import test4; extern void Foo(); void Goo() { switch("c") { case "a": break; //comment this line case "b": break; case "c": break; case "d": break; default: break; } Foo(); } --- test4.d --- module test4; unittest { } --- As you see, the main module does basically nothing, everything compiles, but doesn't link. First I tried this command. >dmd test.d -oftest.exe OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved. test.obj(test) Error 42: Symbol Undefined _D5test212__ModuleInfoZ --- errorlevel 1 It clearly misses test2 module. But why? test2 is nearly empty, there's nothing to link from there! Linker doesn't calm down until you compile and link all 4 modules. Then... >dmd test.d test2.d test3.d test4.d -oftest.exe OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved. test.obj(test) Error 42: Symbol Undefined _D5test33FooFZv --- errorlevel 1 Now comment case "a" line in test3 and it links. I don't understand, why.
dmd test.d -oftest.exe must link the testcase because there's nothing to link from other modules.
This test case now compiles successfully.