This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49388] New: Template class can extend private nested class
- From: "matthew_eanor at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 13 Jun 2011 09:00:58 +0000
- Subject: [Bug c++/49388] New: Template class can extend private nested class
- Auto-submitted: auto-generated
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)