Hi,
I think I have found a bug related to template inheritance: parent class members
seem not to be accessible from public derived classes despite the members'
visibility (public/protected/private).
Please refer to the code below.
The code does not compile, complaining about the variable 'member' not being
defined.
I believe it is a bug because:
- the same compiles fine with non template classes
- the same compiles fine if I inherit from a specifi template (eg hello<int>)
while logically I would expect all of the above to behave in the same way in
this context.
Regards,
Enrico Costanza
---
#include <iostream>
using namespace std;
template <class T>
class hello {
public:
int member;
public:
hello() {}
};
template <class P>
class world: public hello<P> {
public:
world() { member = 9;
cerr << "hello" << endl;
}
};
int main(int arc, char** argv)
{
world<int> hmm;
return 0;
}
--
Summary: member visibility in inherited template classes
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P1
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: enrico_groups at libero dot it
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18311