This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Accept -> in offsetof member-designator (the same as `[0].', PR c/32084)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Jason Merrill <jason at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 9 Jan 2009 21:33:03 +0100
- Subject: Re: [PATCH] Accept -> in offsetof member-designator (the same as `[0].', PR c/32084)
- References: <20090107213401.GI25055@tyan-ft48-01.lab.bos.redhat.com> <de8d50360901091229y63c0cfb7j5fe3b1a8d122f784@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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