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]
Other format: [Raw text]

[Bug c++/24960] New: reference to member var in templated base class won't compile


I get the following error:

>g++ bug.cc
bug.cc: In member function ?bool MyClass<T>::SomeMethod()?:
bug.cc:17: error: ?n? was not declared in this scope

with this simple code:


#include <stdio.h>

template<class T>
class BaseClass {
protected:
        int n;
};

template<class T>
class MyClass : public BaseClass<T> {
public:
        bool SomeMethod();
};

template<class T>
bool MyClass<T>::SomeMethod() {
        n = 0; // This line causes a compiler error
        //this->n = 0; // This line will compile okay
}

int main() {
        printf("hello\n");
}


I discovered this bug while trying to build a simple sample that comes with
ARPACK++.  This makes the entire package unusable.



>g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-shared
--with-system-zlib --libexecdir=/usr/lib --enable-nls
--without-included-gettext --enable-threads=posix --program-suffix=-4.0
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)


-- 
           Summary: reference to member var in templated base class won't
                    compile
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gashlerm at yahoo dot com


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


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