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++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public


When declaring an anonymous union inside a class,
any variable from an anonymous struct contained in the union is accessible 
like a public member, regardless of the access level of the enclosing union.

Bug does only occur when struct and union are BOTH anonymous.

The following sample code, which violates access level, compiles under gcc
3.3.6, 3.4.5 debian prerelease and gcc 4.0.2.

Expected result: gcc should report access level violation.

---- testcase ----

class foo {
private:
  union {
    struct {
      int should_be_private;
    };
  };
};

int main()
{
  foo test;
  test.should_be_private = 1;
}


-- 
           Summary: gcc ignores access level violation: struct variables in
                    anonymous union accessible as public
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at warped-space dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24926


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