This is the mail archive of the 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] Fix second part of PR c++/27601: ICE using offsetof with member functions

Volker Reichelt wrote:
> On  6 Jun, Mark Mitchell wrote:
>> If you're correct that we have to recurse, then I agree -- but why do we
>> have to recurse?
> Thinko on my part. In cases like
>   struct A { int i; };
>   struct B { A a; };
>   struct C { B b; };
>   int j = __builtin_offsetof(C, C::b.a.i);
> we not only have to check whether ".i" is valid, but we also have to
> check whether the first part makes sense.

Wow, I wouldn't expect that to be valid.  I'd expect that the second
argument had to be a member of the type given by the first.  However, if
C allows b.a here, then so should C++, I suppose.

> But for member functions the situation is different (and that's what
> I failed to see): As functions cannot have members, we know that the
> C::b.a part does not contain a member function. Only the last part can
> be a function. And therefore we don't have to recurse to check for
> member functions.


> I'm not sure about TYPE_OBJ_P, though, since this would also flag
> references as errors. We now only emit a warning in this case - even
> for "A& A;" or "B& b;" in the case above. Making this consistent
> would require recursion. Therefore I'd rather only check for

That sounds fine to me.

Mark Mitchell
(650) 331-3385 x713

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