[2/2] doc: document C23 changes to intmax_t

Message ID 20260315203255.123865-3-eggert@cs.ucla.edu (mailing list archive)
State Under Review
Delegated to: DJ Delorie
Headers
Series document improvements for max_align_t, intmax_t |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed

Commit Message

Paul Eggert March 15, 2026, 8:32 p.m. UTC
  * manual/arith.texi (Integers): Say that intmax_t/uintmax_t might
be narrower than some integer types.  Use wording of C23.
Also mention __int128, and that ABI changes if intmax_t changes.
---
 manual/arith.texi | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
  

Comments

DJ Delorie March 18, 2026, 1:47 a.m. UTC | #1
Paul Eggert <eggert@cs.ucla.edu> writes:
> -If you want an integer with the widest range possible on the platform on
> -which it is being used, use one of the following.  If you use these,
> -you should write code that takes into account the variable size and range
> -of the integer.
> +If you want an integer with a wide range, use one of these:

Perhaps "with the widest range of any standard type," ?

>  @itemize @bullet
>  @item intmax_t
>  @item uintmax_t
>  @end itemize
>  
> +@noindent
> +The @code{intmax_t} type is wide enough to hold any signed integer value,
> +with the possible exceptions of signed bit-precise integer types,
> +and of @code{int@var{N}_t} types that are wider than @code{long long int}.
> +Compilers may also support other integer types wider than
> +@code{intmax_t}, such as GCC's @code{__int128}.
> +The @code{uintmax_t} type is like @code{intmax_t},
> +except for unsigned integers.
> +
> +Code that uses @code{intmax_t} or @code{uintmax_t} should take into
> +account the variable size, range and alignment of the types.
> +For example, it is unwise for a public interface to rely on @code{intmax_t},
> +as the interface's ABI can change if a different compiler
> +defines @code{intmax_t} differently.
> +
>  @Theglibc{} also provides macros that tell you the maximum and
>  minimum possible values for each integer data type.  The macro names
>  follow these examples: @code{INT32_MAX}, @code{UINT8_MAX},

Otherwise LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
  

Patch

diff --git a/manual/arith.texi b/manual/arith.texi
index df6d25e0ba..9f442e4bdd 100644
--- a/manual/arith.texi
+++ b/manual/arith.texi
@@ -96,16 +96,28 @@  one of these:
 @item uint_fast64_t
 @end itemize
 
-If you want an integer with the widest range possible on the platform on
-which it is being used, use one of the following.  If you use these,
-you should write code that takes into account the variable size and range
-of the integer.
+If you want an integer with a wide range, use one of these:
 
 @itemize @bullet
 @item intmax_t
 @item uintmax_t
 @end itemize
 
+@noindent
+The @code{intmax_t} type is wide enough to hold any signed integer value,
+with the possible exceptions of signed bit-precise integer types,
+and of @code{int@var{N}_t} types that are wider than @code{long long int}.
+Compilers may also support other integer types wider than
+@code{intmax_t}, such as GCC's @code{__int128}.
+The @code{uintmax_t} type is like @code{intmax_t},
+except for unsigned integers.
+
+Code that uses @code{intmax_t} or @code{uintmax_t} should take into
+account the variable size, range and alignment of the types.
+For example, it is unwise for a public interface to rely on @code{intmax_t},
+as the interface's ABI can change if a different compiler
+defines @code{intmax_t} differently.
+
 @Theglibc{} also provides macros that tell you the maximum and
 minimum possible values for each integer data type.  The macro names
 follow these examples: @code{INT32_MAX}, @code{UINT8_MAX},