public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21500] New: Protected members inaccessable in templated derived class
@ 2005-05-10 18:32 mleone at pixar dot com
2005-05-10 18:35 ` [Bug c++/21500] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: mleone at pixar dot com @ 2005-05-10 18:32 UTC (permalink / raw)
To: gcc-bugs
This should compile but doesn't in g++ 3.4.2 (it works in 3.3):
template<typename T>
class Base {
protected:
T m_member;
};
template<typename T>
class Derived : public Base<T> {
public:
Derived(T val) { m_member = val; }
};
test.cpp:11: error: `m_member' undeclared (first use this function)
The workaround is to add an explicit qualifier:
Derived(T val) { Base<T>::m_member = val; }
A similar issue arises with protected methods, with a different error message:
template<typename T>
class Base {
protected:
BaseMethod() { }
};
template<typename T>
class Derived : public Base<T> {
public:
Derived(T val) { BaseMethod(); }
};
test.cpp:5: error: ISO C++ forbids declaration of `BaseMethod' with no type
test.cpp: In constructor `Derived<T>::Derived(T)':
test.cpp:11: error: there are no arguments to `BaseMethod' that depend on a
template parameter, so a declaration of `BaseMethod' must be available
--
Summary: Protected members inaccessable in templated derived
class
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mleone at pixar dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: Red Hat 3.4.2-6.fc3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21500
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/21500] Protected members inaccessable in templated derived class
2005-05-10 18:32 [Bug c++/21500] New: Protected members inaccessable in templated derived class mleone at pixar dot com
@ 2005-05-10 18:35 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-10 18:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-10 18:35 -------
No the code is invalid, please read the changes page for 3.4.x.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21500
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-10 18:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-10 18:32 [Bug c++/21500] New: Protected members inaccessable in templated derived class mleone at pixar dot com
2005-05-10 18:35 ` [Bug c++/21500] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).