[flang-commits] [flang] 45a8caf - [flang] Fix reversed comparison in RESHAPE() runtime
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Nov 26 12:34:07 PST 2021
Author: Peter Klausler
Date: 2021-11-26T12:34:00-08:00
New Revision: 45a8caf1cdf6a9cbe6dd183df62f22c57e3310ae
URL: https://github.com/llvm/llvm-project/commit/45a8caf1cdf6a9cbe6dd183df62f22c57e3310ae
DIFF: https://github.com/llvm/llvm-project/commit/45a8caf1cdf6a9cbe6dd183df62f22c57e3310ae.diff
LOG: [flang] Fix reversed comparison in RESHAPE() runtime
RESHAPE() fails inappropriately at runtime if the source array
is larger than the result -- which is perfectly valid -- because
of an obviously reversed comparison of their numbers of elements
is activating the runtime asserts meant for the opposite case
(source smaller than result).
Differential Revision: https://reviews.llvm.org/D114474
Added:
Modified:
flang/runtime/transformational.cpp
Removed:
################################################################################
diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index 42381ee097dcc..0ac1d46e64eb4 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -385,7 +385,7 @@ void RTNAME(Reshape)(Descriptor &result, const Descriptor &source,
std::size_t elementBytes{source.ElementBytes()};
std::size_t sourceElements{source.Elements()};
std::size_t padElements{pad ? pad->Elements() : 0};
- if (resultElements < sourceElements) {
+ if (resultElements > sourceElements) {
RUNTIME_CHECK(terminator, padElements > 0);
RUNTIME_CHECK(terminator, pad->ElementBytes() == elementBytes);
}
More information about the flang-commits
mailing list