From 397d9b02a3b163d90314bbc0d238a792bdccd8af Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 1 Jun 2025 15:47:33 -0700 Subject: [PATCH] factor: add platform sanity check * src/factor.c: Check against theoretical platform. --- src/factor.c | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- 2.47.3