From 45a8caf1cdf6a9cbe6dd183df62f22c57e3310ae Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Tue, 23 Nov 2021 13:37:15 -0800 Subject: [PATCH] [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 --- flang/runtime/transformational.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp index 42381ee..0ac1d46 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); } -- 2.7.4