[Bug c++/40843] New: private access violation: compile bad code
sipych at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jul 23 21:41:00 GMT 2009
// 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
More information about the Gcc-bugs
mailing list