Closed cbecerescu closed 4 years ago
D supports nested anonymous unions and structs, the correct fix is to use that instead of accessors. Or have I missed something why this wouldn’t work?
I don't remember why things are the way they are anymore. However, it's true that this compiles fine in D right now:
struct Struct {
union {
int a;
struct {
int b;
union {
int c;
char d;
};
};
};
}
void main() {
Struct s;
s.a = 42;
s.b = 1337;
s.c = 7;
s.d = 'D';
}
An example of this bug is shown here. (the issue being the last two accessors in the translated D code).
My understanding is that, previously, we would only go to the sub-sub members of a given anonymous struct or union. But if the nesting level is deeper than that, then we no longer generate the accessors correctly for the deeper levels.