This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/40649] New: Class access violations
- From: "ivranos at freemail dot gr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Jul 2009 13:31:14 -0000
- Subject: [Bug c++/40649] New: Class access violations
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The compiler allows violations of access control in classes. This is a major
issue.
The following code should not compile, but it compiles:
// The code is a modified version of the code of TC++PL3, page 852, Appendix C.
class Outer
{
typedef int T;
int i;
public:
class Inner
{
int x;
T y; // This should be flagged as an error since T is in private
section of class Outer.
public:
void f(Outer *p, int v);
};
};
void Outer::Inner::f(Outer *p, int v)
{
p->i= v; // This should be flagged as an error since p->i is a private
member of class Outer,
// and class Inner should not have access to it.
}
int main()
{
Outer objOuter;
Outer::Inner objInner;
objInner.f(&objOuter, 4);
}
--
Summary: Class access violations
Product: gcc
Version: 4.3.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ivranos at freemail dot gr
GCC host triplet: gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) - Ubuntu 9.04
x64
GCC target triplet: gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) - Ubuntu 9.04
x64
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40649