This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Possible gcc 3.4.4 bug.
- From: "Phillip Neiswanger" <sigsegv at prodigy dot net>
- To: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Wed, 09 Mar 2005 13:45:28 -0700
- Subject: Possible gcc 3.4.4 bug.
Hello,
I am using FreeBSD 4.9 and the latest gcc 3.4.4 shapshot:
gcc-3.4.4_20050211. I get errors when I try to compile
the following code snippet.
template <class T> class Base
{
public:
int size() { return m_sz; }
protected:
int m_sz;
};
template<class T> class Derived : public Base<T>
{
public:
int size() { return m_sz; }
};
The errors are as follows:
pgn> g++34 t.cc
t.cc: In member function `int Derived<T>::size()':
t.cc:11: error: `m_sz' undeclared (first use this function)
t.cc:11: error: (Each undeclared identifier is reported only once for each
function it appears in.)
If I fully qualify the name, as follows, the errors disappear.
template <class T> class Base
{
public:
int size() { return m_sz; }
protected:
int m_sz;
};
template<class T> class Derived : public Base<T>
{
public:
int size() { return Base<T>::m_sz; }
};
If I use ordinary, non-template classes, as follows, the compiler accepts
the code.
class Base
{
public:
int size() { return m_sz; }
protected:
int m_sz;
};
class Derived : public Base
{
public:
int size() { return m_sz; }
};
Finally, if I use an ordinary base class and a template derived class, as
follows, the compiler accepts the code.
class Base
{
public:
int size() { return m_sz; }
protected:
int m_sz;
};
template<class T> class Derived : public Base
{
public:
int size() { return m_sz; }
};
My understand of C++ code right now is that 'm_sz' should be available to
derived classes reguardless of whether it
is contained in a template or ordinary class. Further, I should not have
to fully qualify it to have access to it.
Have I found bug? How do I determine if it is already reported? How do I
report it?
--
phil