Bug 23682 - gcc 2.96 20000731 fails to compile anonymous unions
Summary: gcc 2.96 20000731 fails to compile anonymous unions
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.0
Hardware: i386
OS: Linux
high
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-01-09 23:44 UTC by Bukola Adeoye
Modified: 2005-10-31 22:00 UTC (History)
0 users

(edit)
Clone Of:
(edit)
Last Closed: 2001-01-31 12:49:08 UTC


Attachments (Terms of Use)

Description Bukola Adeoye 2001-01-09 23:44:47 UTC
Please take a look at the snippet of code below; which models a code style 
I am trying to port onto RedHat 7.0

class Base
{
public:
  union
  {

Comment 1 Bukola Adeoye 2001-01-09 23:56:46 UTC
I am sorry about the earlier message, I unwittingly 'committed' my message. 
Herein is the full description of the bug in question:

class Base
{
public:
  union
  {
    int m_i;
  };
};

class Derived : public Base
{
public:
   union
   {
     int m_i;
   };
};

int main ()
{
  return 1;
}

If I run this snippet of code through the above-mentioned compiler, it spewed 
out the error message appended below. As far as I know this code is in 
compliance with ANSI C++ standard, I cant think of any clause being violated. 
Could you please investigate the problem with your latest compiler, thanks.


=====================Start of compiler 2.96 output=================
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.0)
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/cpp0 -lang-c++ -D__GNUG__=2 -v -
D__GNUC__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -
Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -Acpu
(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_i386__ good.cpp 
good.ii
GNU CPP version 2.96 20000731 (Red Hat Linux 7.0) (cpplib)
 (i386 Linux/ELF)
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++-3
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/cc1plus good.ii -quiet -dumpbase 
good.cpp -version -o good.s
GNU C++ version 2.96 20000731 (Red Hat Linux 7.0) (i386-redhat-linux) compiled 
by GNU C version 2.96 20000731 (Red Hat Linux 7.0).
good.cpp:17: declaration of `int Derived::{anonymous union}::m_i'
good.cpp:7: conflicts with previous declaration `int Base::{anonymous 
union}::m_i'
=====================End of compiler 2.96 output=================



Comment 2 Jakub Jelinek 2001-01-31 12:49:04 UTC
I've submitted a patch for this to gcc-patches as
http://gcc.gnu.org/ml/gcc-patches/2001-01/msg02201.html,
am awaiting approval for this. It will probably make it into the next gcc-c++
rpm.

Comment 3 Jakub Jelinek 2001-02-05 21:04:26 UTC
Fixed in gcc-c++-2.96-73 and above.

Comment 4 Bukola Adeoye 2001-02-19 19:47:43 UTC
Thanks for the fix.


Note You need to log in before you can comment on or make changes to this bug.