W
Wojtek Lerch
Dan Pop said:Maybe they shouldn't, but they are. Since the requirement is only mentioned
in the paragraph dealing with signed types, it only applies to signed types.
This may be surprising and inconsistent, but it's not unclear.
It's not so clear for those familiar with the history of the document.
As late as N869, the text in question was:
7.18.1.1 Exact-width integer types
[#1] The typedef name intN_t designates a signed integer |
type with width N. Thus, int8_t denotes a signed integer |
type with a width of exactly 8 bits.
[#2] The typedef name uintN_t designates an unsigned integer |
type with width N. Thus, uint24_t denotes an unsigned |
integer type with a width of exactly 24 bits. |
OK, so between N869 and C99, the part about no padding was added to #1 but
not to #2. Notice that this is consistent with the fact that even though
6.2.5#6 requires that for each signed type there must be a corresponding
unsigned type, there's no requirement that works the other way around. You
can't have int8_t without uint8_t, but you can have uint8_t without int8_t.
The fourth bullet in 6.3.1.1#1 confirms this: "The rank of any unsigned
integer type shall equal the rank of the corresponding signed integer type,
*if any*". This all seems pretty consistent with the intention to allow
implementation to have exact-width unsigned types with padding, even if the
corresponding signed types cannot be implemented because they would need to
have padding, too.
It is perfectly possible that the intent is to exclude padding bits from
all the exact width integer types. This is strongly suggested by the
name "exact-width". The addition made after N869 is already known to
What does the exact width have with padding bits? It's exact width, not
exact size.
be inconsistent, as it is missing from the following text:
3 These types are optional. However, if an implementation provides
integer types with widths of 8, 16, 32, or 64 bits, it shall
define the corresponding typedef names.
rendering 7.18.1.1p3 inconsistent with 7.18.1.1p1.
Yes, DR #269 talks about this inconsistency. Notice that the Committee
didn't think that allowing the unsigned types to have padding is a defect,
only that changing it should be considered in a future revision of the
standard.