bug-gnulib
[Top][All Lists]
Advanced

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

Re: z/OS enum size pitfall


From: Ben Pfaff
Subject: Re: z/OS enum size pitfall
Date: Tue, 22 Aug 2017 15:01:24 -0700
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Aug 22, 2017 at 10:43:07PM +0200, Tim Rühsen wrote:
> On Dienstag, 22. August 2017 13:25:55 CEST Ben Pfaff wrote:
> > On Tue, Aug 22, 2017 at 04:13:54PM -0400, Daniel Richard G. wrote:
> > > What happens is that BILLION is implicitly typed as an unsigned int,
> > > rather than an int. If you edit the code above to use BILLION2 instead
> > > of BILLION, you'll see the same result on GNU/Linux.
> > 
> > It's odd that they claim that this conforms to the C standard.  C11
> > says, in section 6.4.4.3 "Enumeration constants":
> > 
> >     An identifier declared as an enumeration constant has type int.
> > 
> > It also says in section 6.7.2.2 "Enumeration specifiers":
> > 
> >     The identifiers in an enumerator list are declared as constants that
> >     have type int and may appear wherever such are permitted.
> > 
> > This seems pretty clear to me, so I wonder how this interpretation
> > arises.
> 
> Do you know to which C standard the XLC compiler complies to ?
> 
> C99, 6.7.2.2p4 says
> 
>     Each enumerated type shall be compatible with char, a signed integer 
> type, 
> or an unsigned integer type. The choice of type is 
> implementation-defined,108) 
> but shall be capable of representing the values of all the members of the 
> enumeration.

I don't know what XLC conforms to.

C11 has the same text in 6.7.2.2p4.  The specification for enums has not
changed significantly since C89.

Paul Eggert already explained the distinction between enumeration
constants and enumeration types, so I won't repeat it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]