* lib/xalloc-oversized.h (xalloc_oversized): 1 → 1u. --- ChangeLog | 3 +++ lib/xalloc-oversized.h | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog index ea72f7062e..33a67ff322 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2026-05-25 Paul Eggert <[email protected]> + xalloc-oversized: pacify gcc -Wuseless-cast + * lib/xalloc-oversized.h (xalloc_oversized): 1 → 1u. + quotearg: be nicer on macOS etc Problem reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2026-05/msg00150.html diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h index cecdaec51e..96c5f16570 100644 --- a/lib/xalloc-oversized.h +++ b/lib/xalloc-oversized.h @@ -43,10 +43,12 @@ : malloc (N * (size_t) S)). This is a macro, not a function, so that it works even if an - argument exceeds MAX (PTRDIFF_MAX, SIZE_MAX). */ + argument exceeds MAX (PTRDIFF_MAX, SIZE_MAX). The 1u pacifies + -Wuseless-cast, and unlike a compound literal can appear in an + integer constant expression. */ #if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX # define xalloc_oversized(n, s) \ - __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1) + __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1u) #elif 5 <= __GNUC__ && !defined __clang__ && !defined __ICC \ && PTRDIFF_MAX < SIZE_MAX # define xalloc_oversized(n, s) \ -- 2.54.0
