From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8907 invoked by alias); 17 Nov 2005 21:30:55 -0000 Received: (qmail 8895 invoked by uid 48); 17 Nov 2005 21:30:53 -0000 Date: Thu, 17 Nov 2005 21:30:00 -0000 Subject: [Bug c++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "gcc at warped-space dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2005-11/txt/msg02513.txt.bz2 List-Id: 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