------- Comment #8 from mikulas at artax dot karlin dot mff dot cuni dot cz  
2009-07-07 16:45 -------
> Thus code is undefined you have an acess of a char array as a struct.
> Yes you are only taking the address of an element but it is still
> considered an acess by the standards.

Why is it undefined?

"An object shall have its store value accessed only by an lvalue that has one
of the following types ... * a character type"

So you say that converting the char * pointer to struct * pointer is understood
as "accessing the stored value" by the standard?

The only possible problem could be some hypothetical computer that cannot hold
misaligned pointers to structs (common computers allow unaligned pointers and
trap only on dereferencing unaligned pointers, not on generating them). But
once I know that I have a computer that allows unaligned pointers to structs,
there should be a method how to shut the warning up (with (void *) cast).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40665

Reply via email to