[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
GitOrigin-RevId: 45a8caf1cdf6a9cbe6dd183df62f22c57e3310ae
diff --git a/runtime/transformational.cpp b/runtime/transformational.cpp
index 42381ee..0ac1d46 100644
--- a/runtime/transformational.cpp
+++ b/runtime/transformational.cpp
@@ -385,7 +385,7 @@
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);
}