Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][runtime] Fix total MAXLOC/MINLOC over CHARACTER data #76880

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

klausler
Copy link
Contributor

@klausler klausler commented Jan 4, 2024

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.

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.
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Jan 4, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 4, 2024

@llvm/pr-subscribers-flang-runtime

Author: Peter Klausler (klausler)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/76880.diff

1 Files Affected:

  • (modified) flang/runtime/extrema.cpp (+1-1)
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);
     }
   };

Copy link
Contributor

@clementval clementval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@klausler klausler merged commit 3d6c685 into llvm:main Jan 15, 2024
6 checks passed
@klausler klausler deleted the char-maxloc branch January 15, 2024 18:16
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants