Bug 4745 – Non-uniform handling of commas in static initialization of structs

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-28T11:29:00Z
Last change time
2011-06-11T16:38:33Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
stanislav.blinov

Comments

Comment #0 by stanislav.blinov — 2010-08-28T11:29:37Z
Compiler behaves differently for different cases when handling field initializers for structs: struct S1 { int a, b, c; static immutable S1 C1 = { 1 2 3 }; // no commas here, compiles static immutable S1 C2 = { 1, 2, 3 }; // compiles as well } int foo() { return 3; } struct S2 { int a, b, c; static immutable S2 C1 = { foo() 2 3 }; // compiles (and works) static immutable S2 C2 = { foo() 2, 3 }; // compiles (and works) static immutable S2 C3 = { 2 foo() 3 }; // does not compile: comma expected separating field initializers } Encountered this on 2.048 Windows (AMD64), 2.047 and 2.048 Linux (AMD64)
Comment #1 by braddr — 2011-02-06T15:40:47Z
Mass migration of bugs marked as x86-64 to just x86. The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.
Comment #2 by kennytm — 2011-05-07T23:57:59Z
Whoa! How come the compile will accept the no-comma syntax at all?! It should be rejected if http://d-programming-language.org/declaration.html#StructMemberInitializers is correct.
Comment #3 by bugzilla — 2011-06-11T16:38:18Z