From fc4f457fcc531871e86ecaaffc46ef98249b8e6a Mon Sep 17 00:00:00 2001 From: peter klausler Date: Wed, 16 Jun 2021 16:37:20 -0700 Subject: [PATCH] [flang] Fix ARM/POWER test failure (folding20.f90) Recent code for folding MINVAL() didn't allow for architectures whose C/C++ char type is unsigned, so the value of the maximum Fortran character was incorrect. This was caught by the folding20.f90 test. The fix is to avoid numeric_limits<> and use hard values for max signed integers of various character kinds. Pushing into llvm-project/main to restore ARM/POWER buildbots. --- flang/lib/Evaluate/fold-character.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flang/lib/Evaluate/fold-character.cpp b/flang/lib/Evaluate/fold-character.cpp index a73ed52..385159e 100644 --- a/flang/lib/Evaluate/fold-character.cpp +++ b/flang/lib/Evaluate/fold-character.cpp @@ -79,7 +79,8 @@ Expr> FoldIntrinsicFunction( } else if (name == "min") { return FoldMINorMAX(context, std::move(funcRef), Ordering::Less); } else if (name == "minval") { - auto most{std::numeric_limits::max()}; + // Collating sequences correspond to positive integers (3.31) + SingleCharType most{0x7fffffff >> (8 * (4 - KIND))}; if (auto identity{Identity( StringType{most}, GetConstantLength(context, funcRef, 0))}) { return FoldMaxvalMinval( -- 2.7.4