RE: No effect of -fshort-enums..is it a bug

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

 



----Original Message----
>From: John Love-Jensen
>Sent: 22 September 2005 16:34

> Hi Gaurav,
> 
>> Please confirm which of the two outputs is correct and why is there a
> difference in the output of two versions of compiler?
> 
> Both outputs are "correct".
> 


  No, the standard is entirely unambiguous:

--------------------------------------------------------
6.4.4.3 Enumeration constants
Syntax
1 enumeration-constant:
identifier
Semantics
2 An identifier declared as an enumeration constant has type int.
--------------------------------------------------------

  The enumeration constants denoted by the identifiers a, b, and c are
therefore of type int and must have size 4 (on a standard 32-bit system),
regardless of the size of the enumerated type aa.


> (Neither output is compliant to the standard, of course, as -fshort-enums
> is a deviation from the standard.)

  Nope, the standard is entirely unambiguous:

--------------------------------------------------------
6.7.2.2 Enumeration specifiers

4 Each enumerated type shall be compatible with an integer type. The choice
of type is
implementation-defined,97) but shall be capable of representing the values
of all the
members of the enumeration. The enumerated type is incomplete until after
the } that
terminates the list of enumerator declarations.
--------------------------------------------------------

  The choice of what integer type to use to store a value of an enumerated
type is implementation-defined, and if a char is big enough to represent all
the values, the implementation is at liberty to use a char.



    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux