Andrew Haley <aph <at> redhat.com> writes: > On 01/03/2010 10:14 PM, Joshua Haberman wrote: > > Andrew Haley <aph <at> redhat.com> writes: > "6.3.2.3 > > "A pointer to an object or incomplete type may be converted to a > pointer to a different object or incomplete type. If the resulting > pointer is not correctly aligned for the pointed-to type, the > behavior is undefined. Otherwise, when converted back again, the > result shall compare equal to the original pointer." > > This is *all* you are allowed to do with the converted pointer. You > may not dereference it.
The text you quoted does not contain any "shall not" language about dereferencing, so this conclusion does not follow. > [Section 6.3.2.3] is the core rule that governs C's aliasing. Section 6.5 paragraph 7 contains this footnote: The intent of this list is to specify those circumstances in which an object may or may not be aliased. I am not sure why you discard the significance of this section. Also under your interpretation memcpy(&some_int, ..., ...) is illegal, because memcpy() will write to the int's storage with a pointer type other than int. Josh