[MPlayer-dev-eng] [PATCH] Drop support for gcc-2.95
Uoti Urpala
uoti.urpala at pp1.inet.fi
Wed Jul 12 20:46:27 CEST 2006
On Wed, 2006-07-12 at 13:03 -0400, Rich Felker wrote:
> On Wed, Jul 12, 2006 at 07:54:10PM +0300, Uoti Urpala wrote:
> > On Wed, 2006-07-12 at 12:29 -0400, Rich Felker wrote:
> > > On Wed, Jul 12, 2006 at 10:26:41AM +0300, Uoti Urpala wrote:
> > > > This is valid C. gcc-2.95 miscompiles it, resulting in a segfault on my
> > > > machine.
> > >
> > > It is NOT valid C. The compound literal exists only for the current
> > > statement. After that it ceases to exist and any pointer to it is
> > > invalid.
> >
> > You seem to have quite bad misconceptions about C. From the standard:
>
> So now we're even.
Even what? I don't think I've made any similar mistakes about C if you
mean that.
> > It's not all that clear, it depends on which "array objects" are
> > considered, and those aren't all that precisely defined. I think the
> > issue is that a standard-conforming implementation may assume that 'n'
> > in "a[n]" is within the size of the array when it has explicitly known
> > size, and specifically may optimize "i=a[n];" to "i=a[0];" when 'a' has
> > type "type_t a[1];".
>
> Again this is not valid. foo.a[n] is identical to *(foo.a+n), and it
> is valid to access any object via a character pointer. Since you know
The question is whether anything guarantees foo.a+n is defined. The
section about adding to pointers says the result is undefined unless
foo.a points to an "element of an array object" (with objects that are
not in an array considered as if they were one-element arrays) such that
foo.a+n still fits in the array. There's a special case for char
pointers elsewhere that says pointers to any object can be converted to
character type pointers and increments up to the size of the object
yield pointers to its bytes. I haven't studied the standard enough that
I could be sure there are no other special cases which could affect the
result anywhere, but those sections seem to leave foo.a+n undefined for
all values of n except 0 and 1 (dereferencing the result in the 1 case
being forbidden) at least when foo.a isn't a character array.
More information about the MPlayer-dev-eng
mailing list