This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15894] New: Template inheritance problem with base class member
- From: "marzullo at la-defense dot oilfield dot slb dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jun 2004 12:38:36 -0000
- Subject: [Bug c++/15894] New: Template inheritance problem with base class member
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
When creating template inheritance (see program), we can not access base
template member while in the derivated template.
#include <iostream>
template <typename _type>
class MyClass
{
public:
_type m_value;
};
template <typename _type>
class AnotherClass : public MyClass<_type>
{
public:
void print( void ) const
{
std::cerr << "m_value = " << m_value << '\n';
}
};
int
main( void )
{
AnotherClass<bool> a;
std::cerr << "sizeof(wchar_t) " << sizeof(wchar_t) << '\n';
a.print();
return 0;
}
Reading specs from /opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../../SOURCES/gcc-3.4.0/configure --prefix=/opt/gcc/3.4.0
--enable-threads=posix --enable-languages=c++
Thread model: posix
gcc version 3.4.0
/opt/gcc/3.4.0/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -E -quiet -v
-D_GNU_SOURCE template.cpp -mtune=pentiumpro -o template.ii
ignoring nonexistent directory
"/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
/usr/local/include
/opt/gcc/3.4.0/include
/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/include
/usr/include
End of search list.
/opt/gcc/3.4.0/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -fpreprocessed
template.ii -quiet -dumpbase template.cpp -mtune=pentiumpro -auxbase template
-version -o template.s
GNU C++ version 3.4.0 (i686-pc-linux-gnu)
compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64183
template.cpp: In member function `void AnotherClass<_type>::print() const':
template.cpp:18: error: `m_value' undeclared (first use this function)
template.cpp:18: error: (Each undeclared identifier is reported only once for
each function it appears in.)
Regards
Laurent Marzullo
--
Summary: Template inheritance problem with base class member
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marzullo at la-defense dot oilfield dot slb dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15894