Inner template classes confuse gcc-2.95 and gcc-2.95.1 compiler

Paul Burchard burchard@pobox.com
Sat Aug 28 11:37:00 GMT 1999


Paul Burchard wrote:
> 2.  lookup_name_real() runs up the chain of bindings for the identifier
> `B', checking for the condition LOCAL_BINDING_P.  In our case, there is
> exactly one binding for `B' (detailed below), which indeed refers to the
> desired template `A::B<T>'.  But this binding fails to satisfy
> LOCAL_BINDING_P (why?).
>
> 3.  Since that failed, lookup_name_real() goes on to check the
> enclosing namespace scopes 

According to push_binding(), LOCAL_BINDING_P is the condition that the
binding is attached to the scope of the innermost enclosing class, so
this test should indeed fail for `B'.

But then the logic of lookup_name_nonclass() described above appears to
be incorrect -- there can be "nonclass" scopes between the innermost
enclosing class, and enclosing namespace scopes.  Conclusion: the bug is
in lookup_name_nonclass() (i.e., lookup_name_real() with the `nonclass'
flag set).

This bug was probably not noticed before because the only places that
lookup_name_nonclass() is used (besides template lookup), are
build_new_op() and build_op_delete_call().  In both cases, it is being
used there to look up overload candidates for operators, which cannot
come from intermediate class scopes.

-- 
----------------------------------------------------------------------
Paul Burchard   <burchard@pobox.com>   http://www.pobox.com/~burchard/
----------------------------------------------------------------------


More information about the Gcc-bugs mailing list