[Bug c++/40649] New: Class access violations

ivranos at freemail dot gr gcc-bugzilla@gcc.gnu.org
Sat Jul 4 13:31:00 GMT 2009


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



More information about the Gcc-bugs mailing list