------- Comment #2 from ebotcazou at gcc dot gnu dot org 2009-07-04 06:43 ------- > I think the compiler is assuming "union myblock" has the same > alignment as "struct b_one", which is more strictly aligned than > "struct b_two" because of its double member.
That's right and it's prescribed by the ABI. > I realise that casting &a to (union myblock*) in main may technically > invoke undefined behaviour... but I think the cast is reasonable given > that union myblock contains the type of a. The notion of "reasonable" would be quite tricky to define... it's indeed plain undefined behaviour so a SIGBUS at run time is OK. > One other thing, there is a flag "-mno-faster-structs" which this page > suggests would prevent this sort of ldd/std use > (http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html). Unfortunately > this flag doesn't seem to make any difference to this case. -mno-faster-structs is the default. -- ebotcazou at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ebotcazou at gcc dot gnu dot | |org Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40645