Issue 1051: Standard library integer types wider than intmax_t

Authors: Jay Ghiron
Date: 2026-04-24
Submitted against: C23
Status: Open
Cross-references: 1043

Before C23, the following program was always valid:

#include<stdint.h>
#if SIZE_MAX
int main(){}
#endif

However, uintmax_t is no longer specified as being at least as wide as size_t so this program can be invalid because of:

For all unsigned integer types for which <limits.h> or <stdint.h> define a macro with suffix _WIDTH holding its width N, there is a macro with suffix _MAX holding the maximal value 2N-1 that is representable by the type and that has the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. If the value is in the range of the type uintmax_t (7.22.2.6) the macro is suitable for use in conditional expression inclusion preprocessing directives.

For all signed integer types for which <limits.h> or <stdint.h> define a macro with suffix _WIDTH holding its width N, there are macros with suffix _MIN and _MAX holding the minimal and maximal values -2N-1 and 2N-1-1 that are representable by the type and that have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. If the values are in the range of the type intmax_t (7.22.2.6) the macros are suitable for use in conditional expression inclusion preprocessing directives.

(C23 5.3.5.3.2 "Characteristics of integer types <limits.h>" paragraphs 2 and 3.)

No implementations had trouble with size_t needing to be larger than uintmax_t, so it seems unnecessary to allow this possibility. The same applies to sig_atomic_t, ptrdiff_t, wchar_t, and wint_t. For the types intN_t, uintN_t, int_leastN_t, uint_leastN_t, int_fastN_t, uint_fastN_t, intptr_t, and uintptr_t it seems intentional and useful to allow them to be wider than intmax_t. For example, CHERI has intmax_t and uintmax_t as sixty four bits but pointers are one hundred twenty eight bits.

Suggested correction

Modify C23 7.22.2.6 paragraph 1:

These types are required and have widths which are no less than any of the widths of long long, size_t, ptrdiff_t, wchar_t, wint_t, and sig_atomic_t.