This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]