This is the mail archive of the gcc-patches@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: [PATCH] Accept -> in offsetof member-designator (the same as `[0].', PR c/32084)


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


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