[Issue 516] New: Mutually calling constructors allowed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 15 05:10:46 PST 2006
http://d.puremagic.com/issues/show_bug.cgi?id=516
Summary: Mutually calling constructors allowed
Product: D
Version: 0.174
Platform: PC
URL: http://www.digitalmars.com/d/class.html
OS/Version: Windows
Status: NEW
Keywords: spec
Severity: normal
Priority: P4
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: deewiant at gmail.com
OtherBugsDependingO 511
nThis:
The spec states under "Constructors" that "It is illegal for constructors to
mutually call each other", providing a code snippet similar to the following as
a showcase:
class Foo {
this() { this(1); }
this(int i) { this(); } // illegal, cyclic constructor calls
}
void main() {
Foo foo = new Foo();
}
Yet, this code compiles fine, failing at runtime due to a stack overflow.
If the compiler is not meant to detect this, the restriction seems redundant -
such calls will obviously fail at runtime just as though the constructors were
normal functions, which do not suffer from such a restriction. If the compiler
should, however, detect this, then it is a bug that it currently does not.
--
More information about the Digitalmars-d-bugs
mailing list