This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PR 25512: pointer overflow defined?
Richard Guenther writes:
> On Wed, 21 Dec 2005, Andrew Haley wrote:
>
> > Richard Guenther writes:
> > >
> > > The problem in this PR is that code like in the testcase (from
> > > OpenOffice) assumes that pointer overflow is defined. As the
> > > standard does not talk about wrapping pointer semantics at all (at
> > > least I couldn't find anything about that), how should we treat
> > > this?
> >
> > Look at Section 6.5.6, Para 8. The code is undefined.
>
> This talks about pointers that point to elements of an array
> object. It does not talk about doing arithmetic on arbitrary
> pointer (constants), which is what the code does. Or is a pointer
> always pointing to elements of some array object (being it the
> global heap "array object")?
Section 6.5.6, Para 8 always holds. If p1 is a valid pointer, then it
points to a byte within an object or to an element just past the end
of an array.
Andrew.