Index: flang/lib/Evaluate/fold-reduction.h =================================================================== --- flang/lib/Evaluate/fold-reduction.h +++ flang/lib/Evaluate/fold-reduction.h @@ -260,12 +260,12 @@ element = prod.value; } }}; + auto result{Expr{DoReduction(*array, dim, identity, accumulator)}}; if (overflow) { context.messages().Say( "PRODUCT() of %s data overflowed"_warn_en_US, T::AsFortran()); - } else { - return Expr{DoReduction(*array, dim, identity, accumulator)}; } + return result; } return Expr{std::move(ref)}; } @@ -301,12 +301,12 @@ element = sum.value; } }}; + auto result{Expr{DoReduction(*array, dim, identity, accumulator)}}; if (overflow) { context.messages().Say( "SUM() of %s data overflowed"_warn_en_US, T::AsFortran()); - } else { - return Expr{DoReduction(*array, dim, identity, accumulator)}; } + return result; } return Expr{std::move(ref)}; } Index: flang/test/Evaluate/errors01.f90 =================================================================== --- flang/test/Evaluate/errors01.f90 +++ flang/test/Evaluate/errors01.f90 @@ -163,6 +163,8 @@ real, parameter :: bad3 = dim(huge(1.),-.5*huge(1.)) !CHECK: warning: DIM intrinsic folding overflow integer, parameter :: bad4 = dim(huge(1),-1) + !CHECK: warning: HYPOT intrinsic folding overflow + real, parameter :: bad5 = hypot(huge(0.), huge(0.)) !CHECK: warning: overflow on REAL(8) to REAL(4) conversion x = 1.D40 end subroutine