[Bug c++/31525] New: <member> b was not declared in this scope in inherited template class
edufer at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 10 11:25:00 GMT 2007
Fails on 4.1.2 and 3.4.2. Works on 3.2.2
When compiling the following code:
template <class _T> class A {
protected:
int b;
};
template <class _T> class B : public A<_T> {
public:
void test_ok() {
this->b = 17;
}
void test_fail() {
b = 17;
}
};
The method test_ok compiles OK but the test_fails gets the following error:
bug-gcc.cpp: In member function void B<_T>::test_fail():
bug-gcc.cpp:18: error: b was not declared in this scope
The full command line is:
gcc -v -save-temps bug-gcc.cpp
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure
Thread model: posix
gcc version 4.1.2
/usr/local/libexec/gcc/i686-pc-linux-gnu/4.1.2/cc1plus -E -quiet -v
-D_GNU_SOURCE bug-gcc.cpp -mtune=pentiumpro -fpch-preprocess -o bug-gcc.ii
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../include/c++/4.1.2
/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../include/c++/4.1.2/i686-pc-linux-gnu
/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward
/usr/local/include
/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.2/include
/usr/include
End of search list.
/usr/local/libexec/gcc/i686-pc-linux-gnu/4.1.2/cc1plus -fpreprocessed
bug-gcc.ii -quiet -dumpbase bug-gcc.cpp -mtune=pentiumpro -auxbase bug-gcc
-version -o bug-gcc.s
GNU C++ version 4.1.2 (i686-pc-linux-gnu)
compiled by GNU C version 4.1.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 8b499b4064e5e336c763bb8a820d240c
bug-gcc.cpp: In member function void B<_T>::test_fail():
bug-gcc.cpp:18: error: b was not declared in this scope
Many thanks for your help.
Edu.
--
Summary: <member> b was not declared in this scope in inherited
template class
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: edufer at gmail dot com
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31525
More information about the Gcc-bugs
mailing list