www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3364] New: module with unittest forces entire import chain

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3364

           Summary: module with unittest forces entire import chain
           Product: D
           Version: 2.032
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dfj1esp02 sneakemail.com



05:59:32 PDT ---
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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 05 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3364


Sobirari Muhomori <dfj1esp02 sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid



06:04:16 PDT ---
dmd test.d -oftest.exe
must link the testcase because there's nothing to link from other modules.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 05 2009