This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD Editorial status.
Section: 17.4.1 [cstdint.syn] Status: NAD Editorial Submitter: Martin Sebor Opened: 2008-05-17 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [cstdint.syn].
View all issues with NAD Editorial status.
Discussion:
In specifying the names of macros and types defined in
header <stdint.h>
, C99 makes use of the
symbol N
to accommodate unusual platforms with
word sizes that aren't powers of two. C99
permits N
to take on any positive integer value
(including, for example, 24).
In [stdint.sy] Header <cstdint>
synopsis, C++ on the other hand, fixes the value
of N
to 8, 16, 32, and 64, and specifies only
types with these exact widths.
In addition, paragraph 1 of the same section makes use of a rather
informal shorthand notation to specify sets of macros. When
interpreted strictly, the notation specifies macros such
as INT_8_MIN
that are not intended to be specified.
Finally, the section is missing the usual table of symbols defined in that header, making it inconsistent with the rest of the specification.
Proposed resolution:
I propose to use the same approach in the C++ spec as C99 uses, that
is, to specify the header synopsis in terms of "exposition only" types
that make use of the symbol N
to denote one or
more of a theoretically unbounded set of widths.
Further, I propose to add a new table to section listing the symbols defined in the header using a more formal notation that avoids introducing inconsistencies.
To this effect, in [stdint.sy]
Header <cstdint>
synopsis, replace both the
synopsis and paragraph 1 with the following text:
- In the names defined in the
<cstdint>
header, the symbolN
represents a positive decimal integer with no leading zeros (e.g., 8 or 24, but not 0, 04, or 048). With the exception of exact-width types, macros and types for values ofN
in the set of 8, 16, 32, and 64 are required. Exact-width types, and any macros and types for values ofN
other than 8, 16, 32, and 64 are optional. However, if an implementation provides integer types with widths of 8, 16, 32, or 64 bits, the corresponding exact-width types and macros are required.namespace std { // required types // Fastest minimum-width integer types typedef signed integer type int_fast8_t; typedef signed integer type int_fast16_t; typedef signed integer type int_fast32_t; typedef signed integer type int_fast64_t; typedef unsigned integer type uint_fast8_t; typedef unsigned integer type uint_fast16_t; typedef unsigned integer type uint_fast32_t; typedef unsigned integer type uint_fast64_t; // Minimum-width integer types typedef signed integer type int_least8_t; typedef signed integer type int_least16_t; typedef signed integer type int_least32_t; typedef signed integer type int_least64_t; typedef unsigned integer type uint_least8_t; typedef unsigned integer type uint_least16_t; typedef unsigned integer type uint_least32_t; typedef unsigned integer type uint_least64_t; // Greatest-width integer types typedef signed integer type intmax_t; typedef unsigned integer type uintmax_t; // optionally defined types // Exact-width integer types typedef signed integer type intN_t; typedef unsigned integer type uintN_t; // Fastest minimum-width integer types for values // of N other than 8, 16, 32, and 64 typedef signed integer type uint_fastN_t; typedef unsigned integer type uint_fastN_t; // Minimum-width integer types for values // of N other than 8, 16, 32, and 64 typedef signed integer type uint_leastN_t; typedef unsigned integer type uint_leastN_t; // Integer types capable of holding object pointers typedef signed integer type intptr_t; typedef signed integer type intptr_t; }
[Note to editor: Remove all of the existing paragraph 1 from [stdint.sy].]
Table ??: Header
<cstdint>
synopsis
Type Name(s) Macros: INTN_MIN
INTN_MAX
UINTN_MAX
INT_FASTN_MIN
INT_FASTN_MAX
UINT_FASTN_MAX
INT_LEASTN_MIN
INT_LEASTN_MAX
UINT_LEASTN_MAX
INTPTR_MIN
INTPTR_MAX
UINTPTR_MAX
INTMAX_MIN
INTMAX_MAX
UINTMAX_MAX
PTRDIFF_MIN
PTRDIFF_MAX
PTRDIFF_MAX
SIG_ATOMIC_MIN
SIG_ATOMIC_MAX
SIZE_MAX
WCHAR_MIN
WCHAR_MAX
WINT_MIN
WINT_MAX
INTN_C()
UINTN_C()
INTMAX_C()
UINTMAX_C()
Types: intN_t
uintN_t
int_fastN_t
uint_fastN_t
int_leastN_t
uint_leastN_t
intptr_t
uintptr_t
intmax_t
uintmax_t