[Bug c++/49388] New: Template class can extend private nested class
matthew_eanor at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 13 09:01:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49388
Summary: Template class can extend private nested class
Product: gcc
Version: 4.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: matthew_eanor@hotmail.com
GCC 4.4.5 will happily compile the following where the templated class extends
a private nested class.
#include <iostream>
class A {
private:
class B {
protected:
void doSomething() {
std::cout << "Here\n";
}
};
};
template<typename T>
class C : public A::B {
public:
C() {
this->doSomething();
}
};
int main(void)
{
C<int> c;
}
Access to A::B is private and compilation should fail rather than succeed.
Although I have not personally tried this on a later compiler than 4.4.5, I
have been told that this same bug is present in 4.6.
Note. I originally raised this as a question here
(http://stackoverflow.com/questions/6325291/why-can-i-extend-a-private-nested-class-by-a-template-class)
More information about the Gcc-bugs
mailing list