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?
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- Cc: "gcc\ at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Sun, 10 Jan 2010 11:30:40 +0100
- Subject: Re: Sorry to mention aliasing again, but is the standard IN6_ARE_ADDR_EQUAL really wrong?
- References: <4B491A00.5090502@gmail.com>
Dave Korn <dave.korn.cygwin@googlemail.com> writes:
> Is that really right? The type of the pointer (in6->__s6_addr) that we're
> casting is unsigned char *, so shouldn't it already alias everything anyway
> and dereferencing it be allowed, like it is for the casted (a)? I'll file a
> PR if so. (I can't pretend I find the language in the spec easy to follow.)
IIUC both accesses are actually wrong, but in the case of a there is no
information about the actual target type, so the compiler cannot
optimize. In both cases an object is accessed as type uint32_t, but the
effective type is different. Aliasing is not symmetric, the aliasing
exception only applies to the case of accessing through a character
type, the effective type of the object does not matter.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."