February 29, 2004 BUG? Unions with inner structs | ||||
---|---|---|---|---|
| ||||
The program union U { struct { int a; } struct { int b; } } void main() { printf("%d %d", U.a.offset, U.b.offset); } outputs: 0 4 It is a bug or strange D feature? -- Sark7 |
March 01, 2004 Re: BUG? Unions with inner structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sark7 | Sark7 wrote: > The program > > union U > { > struct { int a; } > struct { int b; } > } > > void main() > { > printf("%d %d", U.a.offset, U.b.offset); > } > > outputs: > 0 4 > > It is a bug or strange D feature? A bug that I've been about to report for a while, but you got there first. I found that it only happens with an anonymous inner struct - a predefined struct seems to work fine. It works if there is only one inner struct and it is put at the end (IIRC) of the union definition. Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit. |
Copyright © 1999-2021 by the D Language Foundation