------- Comment #9 from pinskia at gcc dot gnu dot org 2009-07-07 16:54 ------- >So you say that converting the char * pointer to struct * pointer is understood as "accessing the stored value" by the standard?
No. Let's look at the code: char buffer[512]; (void *)&((struct structure *)(void *)buffer)->x You are accessing a character array via a "struct structure" and then taking the address. This why it is undefined. Even though it does not look like an access in the assembly as it is &a->b is an addition, it is an access according to the C/C++ standard. Also aliasing is not transitive, that is you can access anything via a character type but you cannot access a character by everything (only character types themselves). >the code is valid and the function b() must return a fixed value depending on the endianity of the machine. That __asm__ statement works as a barrier that prevents the compiler from reordering two accesses to "c". Actually even with the memory barrier is still undefined according to the C/C++ standards, it does not mean we won't do what you expect but it means we don't have to do what you expect it to do. This is why we warn about it. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40665