Errors:

..\newmain.cpp:23: error: 'gnat' was not declared in this scope
..\newmain.cpp:24: error: 'grue' was not declared in this scope

These member variables should be in scope because they are inherited. It works
fine for normal classes but not template classes in g++. This compiles fine in
Borland 5.5 and VC2005. I have this same error in both g++ 3.4.5 and 4.4.0. I
used the MinGW 3.4.5 and the MinGW (TDM) 4.4.0 compilers.

I'm running Windows 7 x64 but I also experienced the same problem on RedHat's
g++. I don't know what compiler version was used there.

Source:

template <typename T>
class B {
   protected:
      int gnat;
      int grue;
};

template <typename T>
class A : B<T> {
   public:
      A();
};

template <typename T>
A<T>::A() {
   gnat = 0;
   grue = 0;
}

int main()
{
   A<int> someA;

   return 0;
}


-- 
           Summary: Variable scope problems when inheriting template class
                    members
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: artist at 3dfolio dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40810

Reply via email to