That is,
"*T = X;" may change S (as opposed to changing the memory S
points to).
Ah. The rule that permits the compiler to optimize the long form
into the short here is C89 3.3.16.1:
If the value being stored in an object is accessed
from another
object that overlaps in any way the storage of the first object,
then the overlap shall be exact and the two objects shall have
qualified or unqualified versions of a compatible type; otherwise
the behavior is undefined.
The C99 draft I have has similar language in 6.5.16.1 #3.
This would make memcpy-style copying of objects via char pointers
useless (except for a few cases such as char-sized objects), because it
stores through char objects and then accesses through objects which are
not char-sized (and thus cannot overlap exactly) and/or do not have
types compatible with char.
So I think this must mean something else. I'm going to ask the C
language lawyer I know about this.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse at
rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B