NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/43381: gcc allows invalid anonymous unions



>Number:         43381
>Category:       toolchain
>Synopsis:       gcc allows invalid anonymous unions
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 28 21:40:00 +0000 2010
>Originator:     David A. Holland
>Release:        NetBSD 5.99.22 (20091208)
>Organization:
>Environment:
System: NetBSD tanaqui 5.99.22 NetBSD 5.99.22 (TANAQUI) #31: Tue Dec 8 22:53:35 
EST 2009 dholland@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386

% gcc -v
Using built-in specs.
Target: i486--netbsdelf
Configured with: 
/home/drochner/netbsd/work.src.usbdev/tools/gcc/../../gnu/dist/gcc4/configure 
--target=i486--netbsdelf --enable-long-long --enable-threads 
--enable-__cxa_atexit --with-arch=i486 --with-tune=nocona --disable-multilib 
--disable-symvers --build=i386-unknown-netbsdelf5.99.8 --host=i486--netbsdelf
Thread model: posix
gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)

>Description:

gcc accepts the following clearly bogus declaration:

   enum abc { A, B, C };
   struct foo {
      enum abc type;
      union {
         struct {
            int x;
         } type;
      };
   };

even with -Wall -W. Adding -pedantic causes it to say

   foo.c:8: warning: ISO C doesn't support unnamed structs/unions

which is not particularly pertinent.

Uses of ->type appear to get the enum and not the union member.

>How-To-Repeat:

as above.

>Fix:

dunno. As upstream doesn't care about our gcc, can someone with recent
gcc on hand check if this problem still exists there?



Home | Main Index | Thread Index | Old Index