Bug 946 – (D1 only) Circular reference undetected in some cases
Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2007-02-10T10:54:00Z
Last change time
2013-11-15T20:35:21Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2007-02-10T10:54:05Z
====== 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).