[flang-commits] [flang] 3d6c685 - [flang][runtime] Fix total MAXLOC/MINLOC over CHARACTER data (#76880)

via flang-commits flang-commits at lists.llvm.org
Mon Jan 15 10:16:56 PST 2024


Author: Peter Klausler
Date: 2024-01-15T10:16:52-08:00
New Revision: 3d6c6855c1f0b8570f280adb9a3dbb1f950b9115

URL: https://github.com/llvm/llvm-project/commit/3d6c6855c1f0b8570f280adb9a3dbb1f950b9115
DIFF: https://github.com/llvm/llvm-project/commit/3d6c6855c1f0b8570f280adb9a3dbb1f950b9115.diff

LOG: [flang][runtime] Fix total MAXLOC/MINLOC over CHARACTER data (#76880)

The implementation of MAXLOC/MINLOC without DIM=1 is wrong for CHARACTER
data -- change it to use the character comparator rather than the
numeric comparator.

Fixes llvm-test-suite/Fortran/gfortran/regression/maxloc_string_1.f90.

Added: 
    

Modified: 
    flang/runtime/extrema.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/extrema.cpp b/flang/runtime/extrema.cpp
index edb5d5f47a5acf..281d8c95466ec4 100644
--- a/flang/runtime/extrema.cpp
+++ b/flang/runtime/extrema.cpp
@@ -135,7 +135,7 @@ template <bool IS_MAX> struct CharacterMaxOrMinLocHelper {
     RT_API_ATTRS void operator()(const char *intrinsic, Descriptor &result,
         const Descriptor &x, int kind, const char *source, int line,
         const Descriptor *mask, bool back) const {
-      DoMaxOrMinLoc<TypeCategory::Character, KIND, IS_MAX, NumericCompare>(
+      DoMaxOrMinLoc<TypeCategory::Character, KIND, IS_MAX, CharacterCompare>(
           intrinsic, result, x, kind, source, line, mask, back);
     }
   };


        


More information about the flang-commits mailing list