Summary: ModuleInfo's flags not correct WRT class static
                    ctor/dtor when compiled with -lib
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Steven Schveighoffer <> 2010-11-05 
10:38:53 PDT ---
Given the following 3 modules:

import mod2;

__gshared int y = 2;

shared static this()
    y = C.x;

import mod1;

class C
    __gshared static int x = 1;

    shared static this()
        x = y;

import mod1;
import mod2;
import std.stdio;
void main()
    writefln("x = %d, y = %d", C.x, y);


Clearly there is a cyclic dependency, and x and y will be 2 or 1 depending on
module ctor order.

If I compile with the following lines (on Linux):

dmd -lib -oflibmylib.a mod1.d mod2.d
dmd myapp.d -L-L. -L-lmylib

The compiler builds and myapp runs without any errors, printing x = 1, y = 1. 
The problem stems from the fact that the compiler does not mark mod2 as having
any static ctors.

However, if I compile as:

dmd myapp.d mod1.d mod2.d

Then the compiler builds, but myapp fails with a cyclic dependency failure.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to