[patch] Fix second part of PR c++/27601: ICE using offsetof with member functions
Volker Reichelt
reichelt@igpm.rwth-aachen.de
Tue Jun 6 11:45:00 GMT 2006
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:
=================================================
struct A
{
int foo;
};
struct B
{
void foo();
};
template<typename T> struct C
{
C() { __builtin_offsetof(T, T::foo); }
};
C<A> a; // OK
C<B> b; // error (currently ICE)
=================================================
And instead of duplicating the code in parser.c and pt.c I'd rather
check it in fold_offsetof_1.
> Wouldn't calling invalid_nonstatic_memfn_p fix this?
The problem appears with static *and* non-static member functions.
I don't see how invalid_nonstatic_memfn_p helps in this situation.
Regards,
Volker
More information about the Gcc-patches
mailing list