digitalmars.D.bugs - [Issue 2380] New: static struct initializer accepted as non static initializer
- d-bugmail puremagic.com (29/29) Sep 30 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (9/9) Oct 02 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (10/10) Oct 02 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (20/20) Oct 02 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (15/15) Oct 03 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (10/10) Oct 03 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (14/14) Oct 03 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (5/5) Oct 03 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (4/4) Oct 03 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
- d-bugmail puremagic.com (9/9) Oct 20 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2380
http://d.puremagic.com/issues/show_bug.cgi?id=2380 Summary: static struct initializer accepted as non static initializer Product: D Version: 1.034 Platform: PC OS/Version: All Status: NEW Keywords: accepts-invalid Severity: major Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: tomas famolsen.dk D has different syntax for static struct initializers and struct literals. several threads on the NG has been about this and there are enhancement requests on this tracker as well... dmd currently accepts the invalid code: module structinitbug; struct S { void* ptr; } void main() { S s = {null}; } it seems that there are several issues surrounding initializers lately... I found this due to it actually being used in Tango (xml.Document) and LLVMDC not handling it properly. --
Sep 30 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID Static initializers are allowed for initializing non-statics. It is not a bug. --
Oct 02 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 tomas famolsen.dk changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Keywords|accepts-invalid |spec Resolution|INVALID | It's not documented though, reopening as a spec bug --
Oct 02 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 ------- 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); } --
Oct 02 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 What's more surprising is that not all static initializers are allowed to initialize non-statics: int[] a = [1, 2, 3]; // ok. int[] b = [1 : 2, 3]; // fails. only static arrays can be initialized like this Though it seems to be according to the specs, I don't see the reason why initializers with indexes are special cased. And this one may be considered a bug: void foo() { int[3] a = [ 1:2, 3 ]; // fails. static static arrays, only: static int[3] a = [ 1:2, 3 ]; // ok } --
Oct 03 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |INVALID I agree it's an inconsistent design, but it is not a bug. Static initializer syntax is different. You can enter an enhancement request to change the design. --
Oct 03 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 tomas famolsen.dk changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | Summary|static struct initializer |static struct initializer |accepted as non static |accepted as non static |initializer |initializer is not | |documented but it's still not documented !!! reopening, changing the description a bit. the spec should mention that this is allowed.. --
Oct 03 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 also the point that Christian mentions, that the initializer need not be static is especially surprising given no documentation. --
Oct 03 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 Ok :-) --
Oct 03 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2380 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |FIXED Fixed dmd 1.036 and 2.020 --
Oct 20 2008