public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public @ 2005-11-17 21:30 gcc at warped-space dot de 2005-11-17 21:48 ` [Bug c++/24926] gcc ignores access level violation for anonymous structs pinskia at gcc dot gnu dot org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: gcc at warped-space dot de @ 2005-11-17 21:30 UTC (permalink / raw) To: gcc-bugs 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/24926] gcc ignores access level violation for anonymous structs 2005-11-17 21:30 [Bug c++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public gcc at warped-space dot de @ 2005-11-17 21:48 ` pinskia at gcc dot gnu dot org 2006-02-01 12:20 ` reichelt at gcc dot gnu dot org 2006-12-06 23:37 ` pinskia at gcc dot gnu dot org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-11-17 21:48 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from pinskia at gcc dot gnu dot org 2005-11-17 21:48 ------- Confirmed, I should note that anonymous structs are extensions. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |minor Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2005-11-17 21:48:33 date| | Summary|gcc ignores access level |gcc ignores access level |violation: struct variables |violation for anonymous |in anonymous union |structs |accessible as public | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24926 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/24926] gcc ignores access level violation for anonymous structs 2005-11-17 21:30 [Bug c++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public gcc at warped-space dot de 2005-11-17 21:48 ` [Bug c++/24926] gcc ignores access level violation for anonymous structs pinskia at gcc dot gnu dot org @ 2006-02-01 12:20 ` reichelt at gcc dot gnu dot org 2006-12-06 23:37 ` pinskia at gcc dot gnu dot org 2 siblings, 0 replies; 4+ messages in thread From: reichelt at gcc dot gnu dot org @ 2006-02-01 12:20 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from reichelt at gcc dot gnu dot org 2006-02-01 12:20 ------- The following testcase shows the same problem, but *without* using GCC's extension of anonymous structs: ========================== class A { union { union { int i; }; }; }; int j=A().i; ========================== -- reichelt at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |reichelt at gcc dot gnu dot | |org Keywords| |accepts-invalid, monitored http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24926 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/24926] gcc ignores access level violation for anonymous structs 2005-11-17 21:30 [Bug c++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public gcc at warped-space dot de 2005-11-17 21:48 ` [Bug c++/24926] gcc ignores access level violation for anonymous structs pinskia at gcc dot gnu dot org 2006-02-01 12:20 ` reichelt at gcc dot gnu dot org @ 2006-12-06 23:37 ` pinskia at gcc dot gnu dot org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-12-06 23:37 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from pinskia at gcc dot gnu dot org 2006-12-06 23:37 ------- *** Bug 30097 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |stefan dot gotz at intel dot | |com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24926 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-12-06 23:37 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-11-17 21:30 [Bug c++/24926] New: gcc ignores access level violation: struct variables in anonymous union accessible as public gcc at warped-space dot de 2005-11-17 21:48 ` [Bug c++/24926] gcc ignores access level violation for anonymous structs pinskia at gcc dot gnu dot org 2006-02-01 12:20 ` reichelt at gcc dot gnu dot org 2006-12-06 23:37 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).