This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Correctness question
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'Richard Guenther'" <rguenth at tat dot physik dot uni-tuebingen dot de>,"'Florian Weimer'" <fw at deneb dot enyo dot de>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Tue, 8 Feb 2005 15:40:10 -0000
- Subject: RE: Correctness question
> -----Original Message-----
> From: gcc-owner On Behalf Of Richard Guenther
> Sent: 08 February 2005 14:34
> On Tue, 8 Feb 2005, Florian Weimer wrote:
>
> > * Richard Guenther:
> >
> > > Is it correct for the middle-end to transform
> > >
> > > void foo(int i)
> > > {
> > > int a[4];
> > > if (&a[i] == &a[2147483648U])
> > > abort();
> > > if (i == 2147483648U)
> > > abort();
> > > }
> >
> > Is this valid C? I doubt that even a + 5 is a valid
> expression (a + 4 is okay, though).
>
> Do you mean (char *)&a + 5?
No, he's referring to the fact that it is illegal to index more than one
element past the end of an array. You can take &a[4], but not dereference it
legally, but you aren't even allowed to calculate &a[5] or greater.
cheers,
DaveK
--
Can't think of a witty .sigline today....