This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Sorry to mention aliasing again, but is the standard IN6_ARE_ADDR_EQUAL really wrong?
Hi,
On Sun, 10 Jan 2010, Dave Korn wrote:
> Ok. So if I had four ints, and I wanted to cast the pointers to char
> and compare them as 16 chars, that would be OK, because the chars would
> alias the ints; but in this case, where they started as chars and I cast
> them to ints, those ints don't alias against the original chars. Is
> that an accurate precis?
Yes, this is correct. Many people are surprised by that, as they often
"learned" that 'char' is the catch-all escape from aliasing problems.
This is only true in one direction (accessing anything as chars), but not
in the other (accessing chars as something else).
Ciao,
Michael.