]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
factor: add platform sanity check
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 1 Jun 2025 22:47:33 +0000 (15:47 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Jul 2025 00:12:39 +0000 (17:12 -0700)
* src/factor.c: Check against theoretical platform.

src/factor.c

index 95383556a55832ad8479c2fbe48673d64d34417e..cb0df9e0962d0edd9c25128a3dcf8d08b6a23058 100644 (file)
@@ -134,6 +134,12 @@ typedef intmax_t wide_int;
 #endif
 #define WIDE_UINT_MAX ((wide_uint) -1)
 
+/* Check that we are not on a theoretical (but allowed by
+   POSIX) platform where WIDE_UINT_MAX <= INT_MAX.
+   This could result in undefined behavior due to signed integer
+   overflow if a word promotes to int.  */
+static_assert (INT_MAX < WIDE_UINT_MAX);
+
 #ifndef USE_LONGLONG_H
 /* With the way we use longlong.h, it's only safe to use
    when UWtype = UHWtype, as there were various cases