Bug 5350 – .tupleof lists members of nested anonymous union as members of containing struct
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-12-14T07:54:00Z
Last change time
2010-12-19T22:01:03Z
Assigned to
nobody
Creator
elfy.nv
Comments
Comment #0 by elfy.nv — 2010-12-14T07:54:21Z
struct S2
{
int type;
union {
int i;
string s;
}
}
void main()
{
S2 s2;
foreach (i, Subobj; typeof(s2.tupleof))
{
writeln(s2.tupleof[i].stringof);
}
}
output:
---
s2.type
s2.i
s2.s
---
This in turn leads to wrong behaviour of std.exception.pointsTo, which tries every member of union (read: all kind of invalid pointers) without any clue that they are actually part of nested union.
Comment #1 by bugzilla — 2010-12-19T22:01:03Z
All anonymous unions do is control the layout. The fields *are* part of the enclosing struct's fields. This is as designed. Not a bug.