This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/40843] New: private access violation: compile bad code
- From: "sipych at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jul 2009 21:41:37 -0000
- Subject: [Bug c++/40843] New: private access violation: compile bad code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
// Illegal access to private member not detected, program compiles silently.
// bug found in:
// g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
// g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3
#include <iostream>
class A {
enum { value=1 }; // private
};
template <int i> // bug appears only if B is a template
struct B {
enum { value=A::value }; // <- silently access private member
};
int main() {
std::cout << B<1>::value << std::endl;
return 0;
}
--
Summary: private access violation: compile bad code
Product: gcc
Version: 4.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sipych at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40843