[Issue 668] New: Use of *.di files breaks the order of static module construction

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 9 08:28:47 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=668

           Summary: Use of *.di files breaks the order of static module
                    construction
           Product: D
           Version: 0.176
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: kinaba at is.s.u-tokyo.ac.jp


The spec says that "each module is assumed to depend on any
imported modules being statically constructed first" in module.html.
But when I use *.di interface files, the order seems broken.
Here is an example:

//credit goes to http://pc8.2ch.net/test/read.cgi/tech/1158013550/987
------- lib.d -------
bool initialized;
static this(){ initialized = true; } 
------- main.d -------
import lib;
import std.stdio;
void main(){ } 
static this(){ writefln("lib.initialized? ", lib.initialized); } 

> dmd -c -H lib.d   // generating lib.di
> dmd main.d lib.obj
> main
lib.initialized? false // wrong
> del lib.di        // deleteing b.di
> dmd main.d lib.obj
> main
lib.initialized? true // correct


-- 




More information about the Digitalmars-d-bugs mailing list