From: Paul Eggert Date: Sun, 1 Jun 2025 22:47:33 +0000 (-0700) Subject: factor: add platform sanity check X-Git-Tag: v9.8~242 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=397d9b02a3b163d90314bbc0d238a792bdccd8af;p=thirdparty%2Fcoreutils.git factor: add platform sanity check * src/factor.c: Check against theoretical platform. --- diff --git a/src/factor.c b/src/factor.c index 95383556a5..cb0df9e096 100644 --- a/src/factor.c +++ b/src/factor.c @@ -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