NetBSD Problem Report #43381

From dholland@eecs.harvard.edu  Fri May 28 21:36:02 2010
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 8C98263B873
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 28 May 2010 21:36:02 +0000 (UTC)
Message-Id: <20100528213405.EEA79FADB@tanaqui.eecs.harvard.edu>
Date: Fri, 28 May 2010 17:34:05 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: gcc allows duplicate member names in anonymous unions
X-Send-Pr-Version: 3.95

>Number:         43381
>Category:       toolchain
>Synopsis:       gcc allows duplicate member names in anonymous unions
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 28 21:40:00 +0000 2010
>Closed-Date:    Sun Jan 01 00:55:38 +0000 2017
>Last-Modified:  Sun Jan 01 00:55:38 +0000 2017
>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 (two "type" fields) 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?

>Release-Note:

>Audit-Trail:

From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/43381: gcc allows invalid anonymous unions
Date: Sun, 30 May 2010 14:06:12 -0400

 On Fri, 28 May 2010 21:40:00 +0000 (UTC)
 dholland@eecs.harvard.edu wrote:

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

 I couldn't test with a HEAD gcc but the same behaviour is seen with
 4.4.1 on Linux.
 -- 
 Matt

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/43381: gcc allows invalid anonymous unions
Date: Sat, 31 Dec 2011 20:45:07 +0000

 On Sun, May 30, 2010 at 06:10:05PM +0000, Matthew Mondor wrote:
  >  > dunno. As upstream doesn't care about our gcc, can someone with recent
  >  > gcc on hand check if this problem still exists there?
  >  
  >  I couldn't test with a HEAD gcc but the same behaviour is seen with
  >  4.4.1 on Linux.

 It also happens with NetBSD-current's gcc 4.5.

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 01 Jan 2017 00:55:38 +0000
State-Changed-Why:
fixed as of gcc 4.8, and nobody's going to hunt it down in older gcc.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.