*This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
Core Issues List revision 114a.
See http://www.open-std.org/jtc1/sc22/wg21/ for the official
list.*

2024-04-18

#### 1636.
Bits required for negative enumerator values

**Section: **9.7.1 [dcl.enum]
**Status: **CD5
**Submitter: **Hyman Rosen
**Date: **2013-03-07

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

According to 9.7.1 [dcl.enum] paragraph 7,

For an enumeration whose underlying type is fixed, the values of the
enumeration are the values of the underlying type. Otherwise,
for an enumeration where *e*_{min} is the smallest
enumerator and *e*_{max} is the largest, the values of
the enumeration are the values in the range *b*_{min} to
*b*_{max}, defined as follows: Let *K* be 1 for a
two's complement representation and 0 for a one's complement or
sign-magnitude representation. *b*_{max} is the smallest
value greater than or equal to
max(|*e*_{min}|-*K*,|*e*_{max}|) and
equal to 2^{M}-1, where *M* is a non-negative
integer. *b*_{min} is zero if *e*_{min} is
non-negative and -(*b*_{max}+*K*) otherwise. The
size of the smallest bit-field large enough to hold all the values of
the enumeration type is max(*M*,1) if *b*_{min} is
zero and *M*+1 otherwise.

The result of these calculations is that the number of bits
required 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
|*e*_{max}| to *e*_{max}.

**Proposed resolution (June, 2018):**

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

*b*_{max} is the smallest value greater than or
equal to *max*(|*e*_{min}| - *K*~~,
|~~*e*_{max}|)
, *e*_{max}) and equal to
2^{M} - 1, where *M* is a non-negative
integer.