This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/40843] New: private access violation: compile bad code


// 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]