[PATCH] Accept -> in offsetof member-designator (the same as `[0].', PR c/32084)

Jakub Jelinek jakub@redhat.com
Fri Jan 9 20:48:00 GMT 2009


On Fri, Jan 09, 2009 at 12:29:04PM -0800, Andrew Pinski wrote:
> On Wed, Jan 7, 2009 at 1:34 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > For struct S { struct T { int i; } t[2]; } is
> > offsetof (struct S, t->i) valid, as with static struct S s;
> > &s.t->i is a valid address constant.  The following patch parses
> > it in both C and C++ FEs as [0].  Bootstrapped/regtested on x86_64-linux,
> > ok for trunk?
> 
> I think this will also accept:
> 
> struct S { struct T { int i; } *t; }
> 
> int a = offsetof (struct S, t->i);
> 
> Which is invalid code and why -> was being prevented from being parsed.

It will be accepted/rejected the same as offsetof (struct S, t[0].i),
which is invalid too.
The patch you posted for PR38699 is (supposed to) fix that both.

	Jakub



More information about the Gcc-patches mailing list