This is the mail archive of the gcc-bugs@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]

Re: lookup error message


Dimitri PAPADOPOULOS-ORFANOS wrote:
> 
> Hi,
> 
> This is an improvement request :
> 
...
> The source looks like this:
>         void foo()
>         {
>         }
> 
>         template < typename T >
>         struct A
>         {
>           typedef T foo;
>         };
> 
>         template < typename T >
>         struct B : A< T >
>         {
>           foo x;
>         };
> 
...
> 
> By the way, sorry to ask this here, but is the attached code really
> invalid or is this a GCC bug?

The code is not valid, the warning in the second (legal) example is a gcc bug
(see http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=708&database=gcc).

> A pointer to a paragraph of the C++
> standard anyone?

14.6.2, p3: In the definition of a class template or in the definition of a
member of such a template that appears outside of the template definition, if a
base class of this template depends on a template-parameter, the base class
scope is not examined during name lookup until the class template is
instantiated. [Example: 

    typedef double A;
    template<class T> B {
            typedef int A;
    };
    template<class T> struct X : B<T> {
            A a;                    //   a  has type  double
    };

Regards
Martin

> 
> Dimitri Papadopoulos
> 
>   --------------------------------------------------------------------------------
> 
>    foo.ccName: foo.cc
>          Type: Plain Text (TEXT/plain)

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