Can PR c++/3905 (sizeof on function call in template) be done on 3.2.x?

Michael Matz matz@suse.de
Mon Feb 9 11:05:00 GMT 2004


Hi,

I know that 3.2.x is unmaintained.  Still: is there any remote possibility 
to backport the relevant parts of the 3.3 C++ frontend changes which made 
for instance the below short testcase work there to the 3.2 codebase.

Not knowing the C++ frontend I now looked into this for a day, trying to 
understand the basic problem by running cc1plus of 3.2 and 3.3 in two 
gdb's and stepping through ;-)

What I currently think is that the relevant tree representing the class
S<char> doesn't yet contain the list of member-functions, and so later 
lookups for the call go wrong.  The first difference occuring is already 
that the "call" inside the sizeof expression has a different form.  In 3.2 
it was unresolved, in 3.3 it already is a call_expr of the correct 
function (with the correct return type, which ultimately leads to sizeof 
on that one working).  I then "backported" a bit of parse.y namely the 
parse_finish_call_expr thingy, and now have initially a nice 
method_call_expr in the sizeof_expr.  Still when later instantiating the 
template build_method_call is called again and fails to find 'foo' because 
the member-functions still aren't set.  Hmm.

Okay, my question is: how much work would this be for a more experienced
C++ frontend hacker (like someone who, uhm, at least knows where to look
at ;-) ) to do, and is this feasible at all?


Ciao,
Michael.
----------------------
template <class T>
struct S
{
        static int foo (void);
        enum { val = sizeof (foo()) };
};

int main () { return S<char>::val; }
----------------------



More information about the Gcc mailing list