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


Volker Reichelt wrote:
> On  5 Jun, Mark Mitchell wrote:
>> Volker Reichelt wrote:
>>> While applying
>>>   http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00161.html
>>> I noticed that the following invalid code snippet also triggers an ICE:
>>>
>>>   struct bar {
>>>     void foo();
>>>   };
>>>
>>>   int a = __builtin_offsetof(bar, foo);
>>>
>>> bug.cc:5: internal compiler error: tree check: expected field_decl, have baselink in fold_offsetof_1, at c-common.c:5992
>>> Please submit a full bug report, [etc.]
>> Can't we catch this in the C++ parser?  __builtin_offsetof is handled by
>> its own parsing routine, so before we call fold_offsetof, we already
>> know what EXPR is.
> 
> You can't catch it in the parser for templates:

Good point!  However, you could catch it in a finish_offsetof routine in
semantics.c, called from both the parser and pt.c.  (That routine would
then call fold_offsetof.)

I think it would be better to handle this case in the C++ front-end,
because I don't think the common code should have to issue error
messages about C++-specific constructs.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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