This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public
- From: "gcc at warped-space dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Nov 2005 21:30:53 -0000
- Subject: [Bug c++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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