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:50:39 +0200 (CEST)
- Subject: Re: Type based aliasing
Hi,
On Wed, 2 Oct 2002, Nathan Sidwell wrote:
> void foo (int *ip, float *fp)
> {
> if (ip == fp)
> this_is_unreachable ()
> }
A followup to my last mail. Think about this:
void bar ()
{
int i;
int *ip = &f;
foo ( ip, (float *)ip);
}
Suppose, that in your foo() for the compare 'fp' is casted to 'int*'
(maybe because it has looser alignment). Then it's required per
6.3.2.3 #7 to compare equal to the original pointer, which is ip.
Ciao,
Michael.