[flang-commits] [PATCH] D114474: [flang] Fix reversed comparison in RESHAPE() runtime

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Nov 23 13:41:44 PST 2021


klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.

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).


https://reviews.llvm.org/D114474

Files:
  flang/runtime/transformational.cpp


Index: flang/runtime/transformational.cpp
===================================================================
--- flang/runtime/transformational.cpp
+++ flang/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);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114474.389310.patch
Type: text/x-patch
Size: 572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211123/538215fe/attachment.bin>


More information about the flang-commits mailing list