Thread overview |
---|
June 09, 2008 [Issue 2146] New: Multiple execution of 'static this' defined in template | ||||
---|---|---|---|---|
| ||||
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. -- |
June 09, 2008 [Issue 2146] Multiple execution of 'static this' defined in template | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2146 ------- Comment #1 from samukha@voliacable.com 2008-06-09 08:22 ------- '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; } ---- -- |
June 23, 2008 [Issue 2146] Multiple execution of 'static this' defined in template | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2146 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #2 from bugzilla@digitalmars.com 2008-06-22 19:00 ------- Fixed dmd 1.031 and 2.015 -- |
Copyright © 1999-2021 by the D Language Foundation