[libc][stdfix] Guard DiviFxTest shift edge cases against narrow IntType (#209970)

Fixes riscv32 buildbot failure from #206115.
This commit is contained in:
sohail 2026-07-17 07:10:29 +05:30 committed by GitHub
parent 464b46a73b
commit 7fec267c9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,7 +108,8 @@ public:
// Only valid when integral bits (excluding sign) exceed fraction bits.
// Otherwise 1<<FRACTION_LEN may not fit in IntType.
if constexpr ((FXRep::INTEGRAL_LEN) > FXRep::FRACTION_LEN) {
if constexpr ((FXRep::INTEGRAL_LEN) > FXRep::FRACTION_LEN &&
FXRep::FRACTION_LEN < cpp::numeric_limits<IntType>::digits) {
constexpr IntType epsilon_result = static_cast<IntType>(1)
<< FXRep::FRACTION_LEN;
EXPECT_EQ(func(1, epsilon), epsilon_result);
@ -119,7 +120,8 @@ public:
}
}
if constexpr (has_integral) {
if constexpr (has_integral &&
FXRep::INTEGRAL_LEN < cpp::numeric_limits<IntType>::digits) {
constexpr IntType largest_positive =
((static_cast<IntType>(1) << FXRep::INTEGRAL_LEN) - 1);
EXPECT_EQ(func(largest_positive, static_cast<FXType>(largest_positive)),