Bug 80 - g++ enum and attributed __packed__
Summary: g++ enum and attributed __packed__
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 2.95.2
: P3 normal
Target Milestone: 3.4.0
Assignee: Ben Elliston
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2000-03-05 13:36 UTC by martin
Modified: 2004-07-13 17:35 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description martin 2000-03-05 13:36:00 UTC
 Original-Message-ID: <3882F04F.44C58C89@or.uni-bonn.de>
 Date: Mon, 17 Jan 2000 11:34:55 +0100

 Hello,
 I run into some very essential problem with g++:

 The g++ Compiler does not support the attribute (packed) on enum
 declarations.

 The following line of code compiles with gcc but not with g++:

 enum numbers { zero, one, two, three } __attribute__ ((packed)) ;

 The documentation says:

 packed 

     This attribute, attached to an enum, struct, or union type
   definition, specified that the minimum required memory be used to
   represent the type. Specifying this attribute for struct and union
   types is equivalent to specifying the packed attribute on each of
   the structure or union members.  Specifying the `-fshort-enums'
   flag on the line is equivalent to specifying the packed attribute
   on all enum definitions.  You may only specify this attribute after
   a closing curly brace on an enum definition, not in a typedef
   declaration, unless that declaration also contains the definition
   of the enum.


 The command "g++ -v --save-temps enum.C" returns:

 Reading specs from /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/specs
 gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
  /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/cpp -lang-c++ -v -undef
 -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__
 -Dunix -Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__
 -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix)
 -D__EXCEPTIONS -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386
 -D__i386 -D__i386__ -Di486 -D__i486 -D__i486__ enum.C enum.ii
 GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i386
 Linux/ELF)
 #include "..." search starts here:
 #include <...> search starts here:
  /usr/include/g++
  /usr/lib/g++-include
  /usr/local/include
  /usr/i486-linux/include
  /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/include
  /usr/include
 End of search list.
  /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/cc1plus enum.ii -quiet
 -dumpbase enum.cc -version -o enum.s
 GNU C++ version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i486-linux)
 compiled by GNU C version egcs-2.91.66 19990314 (egcs-1.1.2 release).
 enum.C:4: semicolon missing after declaration of `numbers'

 The file enum.ii (6 lines):
 # 1 "enum.C"



 enum numbers { zero, one, two, three } __attribute__ ((packed))  ;

 -- end of file --

 I found nothing about this under "well known bugs"
 and I hope you can fix this.

 Thanks,
 Karsten Muuss

Release:
2.95.2
Comment 1 Martin v. Loewis 2000-03-08 23:50:15 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed as a bug
Comment 2 Martin v. Loewis 2000-03-09 07:50:15 UTC
From: loewis@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de,
  muuss@or.uni-bonn.de, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/80
Date: 9 Mar 2000 07:50:15 -0000

 Synopsis: g++ enum bug
 
 State-Changed-From-To: open->analyzed
 State-Changed-By: loewis
 State-Changed-When: Wed Mar  8 23:50:15 2000
 State-Changed-Why:
     Confirmed as a bug  
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=80&database=gcc
Comment 3 Gabriel Dos Reis 2001-02-22 05:31:13 UTC
Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-Why: In charge.
Comment 4 Gabriel Dos Reis 2001-02-22 05:31:13 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: I don't think this is a g++ specific behaviour.
    Actually, both gcc and g++ from GCC-2.95.2 exhibit the same
    behaviour -- i.e. reject the code for
      semicolon missing after declarations of 'numbers'
    which is admitely confusing.
Comment 5 Gabriel Dos Reis 2001-02-22 13:31:14 UTC
From: gdr@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org, gdr@gcc.gnu.org,
  martin@loewis.home.cs.tu-berlin.de, muuss@or.uni-bonn.de, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/80
Date: 22 Feb 2001 13:31:14 -0000

 Synopsis: g++ enum bug
 
 Responsible-Changed-From-To: unassigned->gdr
 Responsible-Changed-By: gdr
 Responsible-Changed-When: Thu Feb 22 05:31:13 2001
 Responsible-Changed-Why:
     In charge.
 State-Changed-From-To: analyzed->closed
 State-Changed-By: gdr
 State-Changed-When: Thu Feb 22 05:31:13 2001
 State-Changed-Why:
     I don't think this is a g++ specific behaviour.
     Actually, both gcc and g++ from GCC-2.95.2 exhibit the same
     behaviour -- i.e. reject the code for
       semicolon missing after declarations of 'numbers'
     which is admitely confusing.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=80&database=gcc

Comment 6 muuss 2001-02-28 17:23:55 UTC
From: Karsten Muuss <muuss@or.uni-bonn.de>
To: gdr@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, muuss@or.uni-bonn.de,
   gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/80
Date: Wed, 28 Feb 2001 17:23:55 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=80&database=gcc
 
 It is still not possible to declare a packed enum type with g++.
 
 The line
 
 enum numbers { zero, one, two, three } __attribute__ ((packed));
 
 defines a packed enum type with four values and gcc compiles 
 it properly, but g++ does not (Tested with GCC-2.95.2 of SuSE 7.1).
  
 The test is very simple:
 
 Create two files sample.C and sample.c both containing the line:
 
  enum numbers { zero, one, two, three } __attribute__ ((packed));
 
 Run "gcc -c sample.c" and it will compile properly.
 Run "g++ -c sample.C" and it will fail with:
 
   semicolon missing after declaration of `numbers'
 
 So g++ does not allow any attributes to an enum type declaration.
 
 Please have a second look on this matter.
 
 Thanks,
 -Karsten
Comment 7 Ben Elliston 2001-06-18 18:50:01 UTC
Responsible-Changed-From-To: gdr->bje
Responsible-Changed-Why: I have a patch and am currently testing it.
Comment 8 Ben Elliston 2001-06-18 18:50:01 UTC
State-Changed-From-To: closed->analyzed
State-Changed-Why: This really is a bug!
Comment 9 Wolfgang Bangerth 2002-11-10 13:09:59 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/80: g++ enum and attributed __packed__
Date: Sun, 10 Nov 2002 13:09:59 -0600 (CST)

 Whoever checks this, please also take a look at PR 7385. I think they may 
 be duplicates.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 

Comment 10 Wolfgang Bangerth 2002-11-14 14:23:23 UTC
From: Wolfgang Bangerth <bangerth@apex68.ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/80: g++ enum and attributed __packed__
Date: Thu, 14 Nov 2002 14:23:23 -0600

 Re-confirmed with 3.3 CVS from 2002-11-10 and 3.2.1 pre from the same date.
Comment 11 Neil Booth 2002-12-31 16:44:10 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in 3.4.