[Bug c++/28851] New: template derived class cannot access protected variables in template base class

juechangan at yahoo dot com gcc-bugzilla@gcc.gnu.org
Fri Aug 25 22:55:00 GMT 2006


template derived class cannot access protected variables in template base class

complier: g++ version 4.1.1

error message: 
main.cpp: In constructor ‘D<T>::D()’:
main.cpp:13: error: ‘var’ was not declared in this scope

(compiling with g++ version 3.2, everything is OK)

Entire test program is listed below----------

#include <iostream>
using namespace std;

template <class T>
class B {
protected:
    T var;
};

template <class T>
class D : public B<T> {
public:
    D() { var = 1;}
};

int main() {
    D<int> obj;
    return 0;
}


-- 
           Summary: template derived class cannot access protected variables
                    in template base class
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: juechangan at yahoo dot com


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



More information about the Gcc-bugs mailing list