This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/14374] New: valid unamed struct in a union rejected by gcc
- From: "ahs3 at fc dot hp dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Mar 2004 22:15:06 -0000
- Subject: [Bug c/14374] New: valid unamed struct in a union rejected by gcc
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
If I understand the C standard, section 6.2.5, para 20, on union types
correctly, the following is valid C:
struct a {
int i;
};
struct b {
long l;
};
typedef union {
struct a;
struct b;
} MD;
int main ()
{
MD md;
return 0;
}
When compiled with gcc prior to 3.3, the code is accepted as valid. When
compiled with 3.3 or later versions, the compiler issues the following error:
junk2.c:11: warning: declaration does not declare anything
junk2.c:12: warning: declaration does not declare anything
These line numbers point to the unnamed structs within the union. This seems to
be related to previously closed bugs #6660, #8420 and #10225. If one uses the
-fms-extensions-switch as suggested in #10225, the code does compile. However,
I think this is valid c99 code, and not just a microsoft extension.
If a language lawyer can show me where these semantics are prohibited, then this
is invalid code; if a language lawyer cannot find the prohibition, then gcc
needs to revert to prior behavior and accept this code.
Thanks in advance for any clarification.
--
Summary: valid unamed struct in a union rejected by gcc
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ahs3 at fc dot hp dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: ia64-unknown-linux-gnu
GCC host triplet: ia64-unknown-linux-gnu
GCC target triplet: ia64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14374