Movatterモバイル変換


[0]ホーム

URL:


Issue 1636 - WG21 CWG Issues
Title
Bits required for negative enumerator values
Status
cd5
Section
9.8.1 [dcl.enum]
Submitter
Hyman Rosen

Created on2013-03-07.00:00:00 last changed62 months ago

Messages

msg6399 (view)
Date: 2018-06-15.00:00:00

Proposed resolution (June, 2018):

Change 9.8.1 [dcl.enum] paragraph 8 as follows:

bmax is the smallest value greater than orequal tomax(|emin| -K,|emax|),emax) and equal to2M - 1, whereM is a non-negativeinteger.
msg4276 (view)
Date: 2018-11-15.00:00:00

[Accepted as a DR at the November, 2018 (San Diego) meeting.]

According to 9.8.1 [dcl.enum] paragraph 7,

For an enumeration whose underlying type is fixed, the values of theenumeration are the values of the underlying type. Otherwise,for an enumeration whereemin is the smallestenumerator andemax is the largest, the values ofthe enumeration are the values in the rangebmin tobmax, defined as follows: LetK be 1 for atwo's complement representation and 0 for a one's complement orsign-magnitude representation.bmax is the smallestvalue greater than or equal tomax(|emin|-K,|emax|) andequal to 2M-1, whereM is a non-negativeinteger.bmin is zero ifemin isnon-negative and -(bmax+K) otherwise. Thesize of the smallest bit-field large enough to hold all the values ofthe enumeration type is max(M,1) ifbmin iszero andM+1 otherwise.

The result of these calculations is that the number of bitsrequired for

  enum { N = -1, Z = 0 }

is 1, but the number required for

  enum { N = -1 }

is 2. This is surprising. This could be fixed by changing|emax| toemax.

History
DateUserActionArgs
2020-12-15 00:00:00adminsetmessages: +msg6399
2020-12-15 00:00:00adminsetstatus: drafting -> cd5
2013-05-03 00:00:00adminsetstatus: open -> drafting
2013-03-07 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp