This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: No effect of -fshort-enums..is it a bug
- From: Daniel Jacobowitz <drow at false dot org>
- To: "Gaurav Gautam, Noida" <gauravga at noida dot hcltech dot com>
- Cc: gcc at gcc dot gnu dot org, gcc-help at gcc dot gnu dot org
- Date: Wed, 21 Sep 2005 10:19:03 -0400
- Subject: Re: No effect of -fshort-enums..is it a bug
- References: <40CC5CC7CDACC048B1299C57025E330CFD5F6C@HSDLNTD1110010.noida.hcltech.com>
On Wed, Sep 21, 2005 at 07:03:49PM +0530, Gaurav Gautam, Noida wrote:
> Thanks for the reply,
>
> But why is there a difference in the output of same tc, with an old gcc
> compiler and a new version of compiler.
>
> Was there a bug in the earlier gcc.
>
> I have a doubt.
>
> Gcc manual says that
>
> "-fshort-enums
> Allocate to an enum type only as many bytes as it needs for the
> declared range of possible values. Specifically, the enum type will be
> equivalent to the smallest integer type which has enough room."
>
> Does -fshort-enum guides the size of enumeration type or the size of
> enumerator constant ?
C99, section 6.7.2.2:
[#3] The identifiers in an enumerator list are declared as
constants that have type int and may appear wherever such
are permitted.
...
[#4] Each enumerated type shall be compatible with char, a
signed integer type, or an unsigned integer type. The
choice of type is implementation-defined, but shall be
capable of representing the values of all the members of the
enumeration.
I'm not 100% sure what #3 means for enumerators whose value does not
fit in the range of "int", but it's pretty clear that the
implementation is not allowed to change the type of enumerators.
--
Daniel Jacobowitz
CodeSourcery, LLC