Title
cstdint.syn inconsistent with C99
Status
nad editorial
Section
[cstdint.syn]
Submitter
Martin Sebor

Created on 2008-05-17.00:00:00 last changed 163 months ago

Messages

Date: 2010-10-21.18:28:33

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 cstdint.syn Header <cstdint> synopsis, replace both the synopsis and paragraph 1 with the following text:

  1. In the names defined in the <cstdint> header, the symbol N 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 of N in the set of 8, 16, 32, and 64 are required. Exact-width types, and any macros and types for values of N 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 cstdint.syn.]

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
Date: 2008-05-17.00:00:00

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 cstdint.syn 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.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg4018
2008-05-17 00:00:00admincreate