http://d.puremagic.com/issues/show_bug.cgi?id=4967
Summary: { } struct literals not documented, and not working Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: ah0801...@yahoo.com --- Comment #0 from Austin Hastings <ah0801...@yahoo.com> 2010-10-01 06:24:48 PDT --- I unthinkingly created a struct literal like S s = { 9 }; and it worked (which, now that I'm complaining about it, I can't find documented in the chm). But this format doesn't appear to initialize any other fields: $ cat test.d import std.stdio; struct S { int key; int x = 1; void dump() { writefln("%s %s", key, x); } } void main() { S s1; s1.dump; S s2 = { 9 }; s2.dump; } This code prints: $ dmd -run test.d 0 1 9 1310436 Note the trash in the second variable. I am not sure what the correct solution is - should struct literals require ctor style, or use static-initializer format and an implicit copy? - but I would certainly have appreciated a warning, if nothing else, when I started compiling code like this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------