Bug 2485 – non-static initialization of struct using static initializer syntax generates wrong code
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2008-12-02T11:42:00Z
Last change time
2014-03-01T00:36:49Z
Keywords
wrong-code
Assigned to
nobody
Creator
tomas
Comments
Comment #0 by tomas — 2008-12-02T11:42:00Z
The example from the spec added to document that static struct initializer syntax is allowed for non-static initialization doesn't do what it's supposed to with DMD.
I've produced a test case from it:
struct S {
int a; int b; int c; int d = 7;
}
void test(int i) {
S s = { 1, i }; // q.a = 1, q.b = i, q.c = 0, q.d = 7
assert(s.a == 1);
assert(s.b == i);
assert(s.c == 0); // line 8
assert(s.d == 7);
}
void main() {
test(42);
}
$ dmd foo.d
$ ./foo
Error: AssertError Failure foo.d(8)
Comment #1 by clugdbug — 2010-10-07T07:35:43Z
*** Issue 4552 has been marked as a duplicate of this issue. ***