public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cfranz at aldon dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/25322] New: ISO compliance of defining structs in anonymous unions Date: Thu, 08 Dec 2005 23:05:00 -0000 [thread overview] Message-ID: <bug-25322-11844@http.gcc.gnu.org/bugzilla/> (raw) $ cat testunion.cpp // testunion.cpp static union { struct n { int I2; } S2; }; // Case 1 static union { struct { int I1; } S1; }; // Case 2 struct foo { union { struct n { int I2; } S2; }; // Case 3 union { struct { int I1; } S1; }; // Case 4 }; void func() { union { struct n { int I2; } S2; }; // Case 5 union { struct { int I1; } S1; }; // Case 6 } $ g++ --version g++ (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ -c -pedantic testunion.cpp testunion.cpp:8: error: `struct foo::<anonymous union>::n' invalid; an anonymous union can only have non-static data members g++ reports an error only in Case 3, regardless of the settings of -pedantic or -pedantic-errors, but as I understand it all six cases violate the C++ standard. Accordingly, Comeau and xlc++ reject all six cases in strict mode, and accept them with warnings in relaxed mode. This behavior is consistent for at least versions 3.4.4 and 3.3.2. -- Summary: ISO compliance of defining structs in anonymous unions Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: cfranz at aldon dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25322
next reply other threads:[~2005-12-08 23:05 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-12-08 23:05 cfranz at aldon dot com [this message] 2005-12-08 23:36 ` [Bug c++/25322] " pinskia at gcc dot gnu dot org 2005-12-09 5:21 ` bangerth at dealii dot org 2006-03-10 16:25 ` jvalenzu at infinite-monkeys dot org 2006-05-11 23:27 ` cfranz at aldon dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-25322-11844@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).