[Issue 2380] static struct initializer accepted as non static initializer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 2 09:05:14 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380
------- Comment #3 from kamm-removethis at incasoftware.de 2008-10-02 11:05 -------
What I found surprising was that you can use static initializers to initialize
non-statics with non-static data. This passes on DMD and LLVMDC:
class C
{
struct S {
C ptr;
}
S foo() {
S loc = {this};
return loc;
}
}
void main()
{
auto c = new C;
assert(c.foo().ptr is c);
}
--
More information about the Digitalmars-d-bugs
mailing list