From 7cdeffa47c66a966a5c53ba863f763f2f6a01107 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Fri, 21 Mar 2025 14:20:20 -0500 Subject: [PATCH] [libc] Suppress GCC loop optimization warning Summary: This appears to be a false positive on some versions of GCC. --- libc/src/__support/big_int.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h index 85db31d01399a..25dddfef9ca8c 100644 --- a/libc/src/__support/big_int.h +++ b/libc/src/__support/big_int.h @@ -790,11 +790,21 @@ struct BigInt { remainder[pos] = rem; } + // GCC currently emits a false-positive warning on this for some compilers. +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waggressive-loop-optimizations" +#endif + // Set the remaining lower bits of the remainder. for (; pos > 0; --pos) { remainder[pos - 1] = val[pos - 1]; } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + *this = quotient; return remainder; } @@ -851,8 +861,8 @@ struct BigInt { result[i] = lhs[i] OP rhs[i]; \ return result; \ } \ - LIBC_INLINE friend constexpr BigInt operator OP##=(BigInt &lhs, \ - const BigInt &rhs) { \ + LIBC_INLINE friend constexpr BigInt operator OP## = \ + (BigInt & lhs, const BigInt &rhs) { \ for (size_t i = 0; i < WORD_COUNT; ++i) \ lhs[i] OP## = rhs[i]; \ return lhs; \