This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Type based aliasing
- From: Michael Matz <matz at suse dot de>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Wed, 2 Oct 2002 23:46:13 +0200 (CEST)
- Subject: Re: Type based aliasing
Hi,
On Wed, 2 Oct 2002, Nathan Sidwell wrote:
> Hi,
> Do C's type based aliasing rules mean the following?
> void foo (int *ip, float *fp)
> {
> if (ip == fp)
> this_is_unreachable ()
> }
Why should it? The accessed values are 'ip' and 'fp' itself and they are
accessed through their effective type. So 6.5.7 is fullfilled, ergo the
accesses to 'ip' and 'fp' are defined. The compare itself is Ok, as even
if everything breaks, one of the two pointer can be converted to the other
pointer type, which is only undefined, if alignment rules of that type are
not followed.
Ciao,
Michael.