Bug 44 – forward referenced anonymous union in struct size discrepancy
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-03-12T14:22:00Z
Last change time
2014-02-15T02:08:15Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
regan
Comments
Comment #0 by regan — 2006-03-12T14:22:17Z
If B is declared before A, or the union in A is named (and an instance added) then the sizeof A is 12 as it should be. In the example below it is 8.
struct A {
int a;
union {
int c;
B b;
}
}
struct B {
int b1;
int b2;
}
void main()
{
A a;
assert(A.sizeof == 12);
}