[Bug c++/19189] New: A derived template cannot access base template members without using this
amos at ilogix dot com
gcc-bugzilla@gcc.gnu.org
Wed Dec 29 14:30:00 GMT 2004
If you try to access a member of a base template from a derived template (event
if the member is public) you are getting a compilation error.
This is a regression related to previous versions of the compiler (worked in
3.3.3) and I think its not ANSI C++ as well.
For example, compiling the following code (in test.cpp) will issue these errors:
$ g++ -c test.cpp
test.cpp: In member function `virtual bool Derived<Concept>::test(Concept)':
test.cpp:21: error: `xxx' undeclared (first use this function)
test.cpp:21: error: (Each undeclared identifier is reported only once for each f
unction it appears in.)
------------
test.cpp
------------
// The base template
template <class Concept> class Base
{
public :
int xxx;
};
// The derived template
template <class Concept> class Derived : public Base<Concept>
{
public :
bool test(Concept p)
{
return (xxx > 10); // to fix this I need to modify it to: return
(this->xxx > 10);
}
};
// usage
bool call_test(Derived<int>& d)
{
return d.test(5);
}
--
Summary: A derived template cannot access base template members
without using this
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: amos at ilogix dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: gcc version 3.4.2 (mingw-special)
GCC host triplet: MinGW on WinXP
GCC target triplet: MinGW on WinXP
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19189
More information about the Gcc-bugs
mailing list