From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Sun, 7 Feb 2010 12:01:16 -0800 Message-ID: Subject: Re: [9fans] NaN, +Inf, and -Inf, constants? From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=000e0cd2dc62b68026047f08252a Topicbox-Message-UUID: cfde25c6-ead5-11e9-9d60-3106f5b1d025 --000e0cd2dc62b68026047f08252a Content-Type: text/plain; charset=UTF-8 On Sun, Feb 7, 2010 at 2:46 AM, Charles Forsyth wrote: > h% cat en.c > enum{ > Fred= 1.5 > }; > double f = Fred; > h% 8c -S en.c > DATA f+0(SB)/8,$(1.50000000000000000e+00) > GLOBL f+0(SB),$8 > END , > > bug or quirk? > what do you think? > i swear i tested this before i replied... seems like a bug to me. the spec is pretty clear: 6.7.2.2 Enumeration specifiers Syntax [#1] enum-specifier: enum identifier-opt { enumerator-list } enum identifier-opt { enumerator-list , } enum identifier enumerator-list: enumerator enumerator-list , enumerator enumerator: enumeration-constant enumeration-constant = constant-expression Constraints [#2] The expression that defines the value of an enumeration constant shall be an integer constant expression that has a value representable as an int. russ --000e0cd2dc62b68026047f08252a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sun, Feb 7, 2010 at 2:46 AM, Charles Forsyth <forsyth@terzarima.net> wr= ote:
h% cat en.c
enum{
=C2=A0 =C2=A0 =C2=A0 =C2=A0Fred=3D 1.5
};
double f =3D Fred;
h% 8c -S en.c
=C2=A0 =C2=A0 =C2=A0 =C2=A0DATA =C2=A0 =C2=A0f+0(SB)/8,$(1.500000000000000= 00e+00)
=C2=A0 =C2=A0 =C2=A0 =C2=A0GLOBL =C2=A0 f+0(SB),$8
=C2=A0 =C2=A0 =C2=A0 =C2=A0END =C2=A0 =C2=A0 ,

bug or quirk?
what do you think?

i swear i tested thi= s before i replied...

seems like a bug to me. =C2=A0the= spec is pretty clear:

=C2=A0=C2=A0 =C2=A0 = =C2=A0 6.7.2.2 =C2=A0Enumeration specifiers

=C2=A0=C2=A0 =C2=A0 =C2=A0 Syntax

<= div>=C2=A0=C2=A0 =C2=A0 =C2=A0 [#1]

=C2=A0=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 enum-specifier:
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 enum identifier-opt { enumerator-list }
=C2=A0=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 enum identif= ier-opt { enumerator-list , }
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 enum identifier

=C2=A0=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 enumerator-list:
=C2=A0=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 enume= rator
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 enumerator-list , enumerator

=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 enumerato= r:
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 enumeration-constant
=C2=A0=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 enumeration-con= stant =3D constant-expression

=C2=A0=C2=A0 =C2=A0 = =C2=A0 Constraints

=C2=A0=C2=A0 =C2=A0 =C2=A0 [#2] The expression that defines = the value of an enumeration
=C2=A0=C2=A0 =C2=A0 =C2=A0 constant s= hall be an integer constant expression that has =C2=A0a
=C2=A0=C2= =A0 =C2=A0 =C2=A0 value representable as an int.

russ
--000e0cd2dc62b68026047f08252a--