[Issue 946] New: Circular reference undetected in some cases

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 10 08:54:11 PST 2007


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

           Summary: Circular reference undetected in some cases
           Product: D
           Version: 1.005
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: minor
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: thecybershadow at gmail.com


====== A.d ======

module A;

import std.stdio;
import B;

int Avar;

static this()
{
        Avar = 5;
        writefln(Bvar);
}

void main()
{
}

====== B.d ======

module B;

import std.stdio;
import C;

int Bvar;

static this()
{
        Bvar = 5;
        writefln(Avar);
}

====== C.d ======

module C;

public import A;

=================

The program compiles, and outputs:

0
5

(A's constructor gets called before B's).

Related code is in _moduleCtor2 from moduleinit.d - if a module has no static
constructors/destructors, any circular references in its imported modules are
ignored (the skip parameter).


-- 



More information about the Digitalmars-d-bugs mailing list