Skip to content

Commit

Permalink
[flang][runtime] Fix NORM2([negative, ...])
Browse files Browse the repository at this point in the history
NORM2 is broken for arrays that start with a negative number
because it sets the initial running max_ value to that number
rather than to its absolute value.

Differential Revision: https://reviews.llvm.org/D155976
  • Loading branch information
klausler committed Jul 21, 2023
1 parent 863e812 commit b7585c7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion flang/runtime/extrema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ template <int KIND> class Norm2Accumulator {
bool Accumulate(Type x) {
auto absX{std::abs(static_cast<AccumType>(x))};
if (!max_) {
max_ = x;
max_ = absX;
} else if (absX > max_) {
auto t{max_ / absX}; // < 1.0
auto tsq{t * t};
Expand Down

0 comments on commit b7585c7

Please sign in to comment.