[flang-commits] [PATCH] D132677: [flang][runtime] Fix MINVAL([CHARACTER(2)::])

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Aug 25 10:46:04 PDT 2022


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

The result of MINVAL over an empty default character array should
(per the standard) have a 127 in every character position, not just
the first.


https://reviews.llvm.org/D132677

Files:
  flang/runtime/extrema.cpp


Index: flang/runtime/extrema.cpp
===================================================================
--- flang/runtime/extrema.cpp
+++ flang/runtime/extrema.cpp
@@ -423,12 +423,9 @@
     if (extremum_) {
       std::memcpy(p, extremum_, byteSize);
     } else {
-      // empty array
-      if constexpr (KIND == 1) { // ASCII
-        *p = IS_MAXVAL ? 0 : 127; // 127 required by standard
-      } else {
-        std::memset(p, IS_MAXVAL ? 0 : 255, byteSize);
-      }
+      // empty array; fill with character 127 if ASCII as required
+      // by the standard, otherwise set all of the bits.
+      std::memset(p, IS_MAXVAL ? 0 : KIND == 1 ? 127 : 255, byteSize);
     }
   }
   bool Accumulate(const Type *x) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132677.455644.patch
Type: text/x-patch
Size: 717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220825/20f4d8b3/attachment-0001.bin>


More information about the flang-commits mailing list