[Issue 9697] New: removing imports or static constructors from di files can break runtime initialization order

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 12 00:05:37 PDT 2013


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

           Summary: removing imports or static constructors from di files
                    can break runtime initialization order
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: r.sagitario at gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario at gmx.de> 2013-03-12 00:05:28 PDT ---
Created an attachment (id=1199)
demonstrate broken init order with optimized di files

D source files often import modules that are not needed for the declaration of
public symbols in the module, but by their implementation. When reducing
dependencies from di import files by removing imports, the runtime
initialization order can be broken.

This is caused by a module not being part of the dependency list in the module
info, if it has no static constructor/destructor and none of its imports has
one, transitively.

See the attached file for an example.

The straight forward solution is to always add imported modules to the
dependency list. This has the drawback that C wrapper header files will always
need to have a static library that contains the module info declarations.

It might work to just add "static this();" to di files that have removed
imports, if it is known to depend on these modules during runtime
initialization. Adding a declaration for non-existing code seems like a dirty
hack, there should be some more explicite way...

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


More information about the Digitalmars-d-bugs mailing list