diff --git a/flang/include/flang/Evaluate/integer.h b/flang/include/flang/Evaluate/integer.h --- a/flang/include/flang/Evaluate/integer.h +++ b/flang/include/flang/Evaluate/integer.h @@ -805,9 +805,13 @@ if (Part ypart{y.LEPart(k)}) { BigPart xy{xpart}; xy *= ypart; - // && to < (2 * parts) was added to avoid GCC < 8 build failure - // on -Werror=array-bounds - for (int to{ j + k }; xy != 0 && to < (2 * parts); ++to) { +#if defined __GNUC__ && __GNUC__ < 8 + // && to < (2 * parts) was added to avoid GCC < 8 build failure on + // -Werror=array-bounds. This can be removed if -Werror is disable. + for (int to{j + k}; xy != 0 && to < (2 * parts); ++to) { +#else + for (int to{j + k}; xy != 0; ++to) { +#endif xy += product[to]; product[to] = xy & partMask; xy >>= partBits; diff --git a/flang/lib/Decimal/big-radix-floating-point.h b/flang/lib/Decimal/big-radix-floating-point.h --- a/flang/lib/Decimal/big-radix-floating-point.h +++ b/flang/lib/Decimal/big-radix-floating-point.h @@ -179,10 +179,13 @@ if (remove >= digits_) { digits_ = 0; } else if (remove > 0) { +#if defined __GNUC__ && __GNUC__ < 8 // (&& j + remove < maxDigits) was added to avoid GCC < 8 build failure - // on -Werror=array-bounds - for (int j{ 0 }; j + remove < digits_ && (j + remove < maxDigits); - ++j) { + // on -Werror=array-bounds. This can be removed if -Werror is disable. + for (int j{0}; j + remove < digits_ && (j + remove < maxDigits); ++j) { +#else + for (int j{0}; j + remove < digits_; ++j) { +#endif digit_[j] = digit_[j + remove]; } digits_ -= remove;