digitalmars.D.bugs - [Issue 2146] New: Multiple execution of 'static this' defined in template
- d-bugmail puremagic.com (45/45) Jun 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2146
- d-bugmail puremagic.com (31/31) Jun 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2146
- d-bugmail puremagic.com (9/9) Jun 22 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2146
http://d.puremagic.com/issues/show_bug.cgi?id=2146 Summary: Multiple execution of 'static this' defined in template Product: D Version: 1.030 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: samukha voliacable.com File a: ---- module a; import b; alias Foo!(int) foo; void main() { } ---- File b: ---- module b; import std.stdio; template Foo(T) { T x; static this() { writefln("Initing " ~ T.stringof); T x = T.init; // less trivial initialization here. } } void baz() { alias Foo!(int) bar; } ---- Output: Initing int Initing int Note that the constructor is executed only once if we move 'alias Foo!(int) bar;' out of baz() to the scope of module b. --
Jun 09 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2146 'T x = T.init;' in the template should read 'x = T.init;', sorry: File a: ---- module a; import b; alias Foo!(int) foo; void main() { } ---- File b: ---- module b; import std.stdio; template Foo(T) { T x; static this() { writefln("Initing " ~ T.stringof); x = T.init; // less trivial initialization here. } } void baz() { alias Foo!(int) bar; } ---- --
Jun 09 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2146 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Fixed dmd 1.031 and 2.015 --
Jun 22 2008