www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 946] New: Circular reference undetected in some cases

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: thecybershadow 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).


-- 
Feb 10 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=946


thomas-dloop kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows                     |All




------- Comment #1 from thomas-dloop kuehne.cn  2007-04-06 06:29 -------
Added to DStress as
http://dstress.kuehne.cn/norun/i/import_20_A.d
http://dstress.kuehne.cn/norun/i/import_20_B.d
http://dstress.kuehne.cn/norun/i/import_20_C.d


-- 
Apr 06 2007