This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Templates and scope (gcc 3.4.0)
- From: Bjørn Reese <br at systematic dot dk>
- To: <gcc-bugs at gcc dot gnu dot org>
- Date: Wed, 9 Jun 2004 17:46:27 +0200
- Subject: Templates and scope (gcc 3.4.0)
Description: gcc 3.4.0 cannot see inherited member variable for templates. It works fine when compiled with gcc 3.3.1.
[br@lillefix:/home/br/junk] uname -a
SunOS lillefix 5.8 Generic_108528-13 sun4u sparc SUNW,UltraAX-i2
[br@lillefix:/home/br/junk] /prj/pack/gcc/3.4.0/bin/g++ -v
Reading specs from /part1/pack/gcc/3.4.0/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.0/specs
Configured with: ../gcc-3.4.0/configure --prefix=/prj/pack/gcc/3.4.0 --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls --enable-languages=c,c++ --disable-libgcj
Thread model: posix
gcc version 3.4.0
[br@lillefix:/home/br/junk] cat tmplscope.cpp
// Fails on gcc 3.4.0
template <class T>
class Base
{
protected:
T* pointer;
};
template <class T>
class Derived : public Base<T>
{
public:
~Derived();
};
template <class T>
Derived<T>::~Derived()
{
delete pointer; // Problem is here
}
[br@lillefix:/home/br/junk] /prj/pack/gcc/3.3.1/bin/g++ -c tmplscope.cpp
[br@lillefix:/home/br/junk] /prj/pack/gcc/3.4.0/bin/g++ -c tmplscope.cpp
tmplscope.cpp: In destructor `Derived<T>::~Derived()':
tmplscope.cpp:20: error: `pointer' undeclared (first use this function)
tmplscope.cpp:20: error: (Each undeclared identifier is reported only once for each function it appears in.)
[br@lillefix:/home/br/junk] cat tmplscope.ii
# 1 "tmplscope.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "tmplscope.cpp"
template <class T>
class Base
{
protected:
T* pointer;
};
template <class T>
class Derived : public Base<T>
{
public:
~Derived();
};
template <class T>
Derived<T>::~Derived()
{
delete pointer;
}
PS: I submit this bug report by email because I do not wish to register this email account anywhere, sorry.