diff --git a/flang/lib/Evaluate/fold-integer.cpp b/flang/lib/Evaluate/fold-integer.cpp --- a/flang/lib/Evaluate/fold-integer.cpp +++ b/flang/lib/Evaluate/fold-integer.cpp @@ -331,14 +331,12 @@ if constexpr (T::category == TypeCategory::Logical) { // array(at) .EQV. value? static_assert(WHICH == WhichLocation::Findloc); - cmp.emplace( - ConvertToType(Expr{LogicalOperation{ - LogicalOperator::Eqv, Expr{Constant{std::move(element)}}, - Expr{Constant{*value}}}})); + cmp.emplace(ConvertToType( + Expr{LogicalOperation{LogicalOperator::Eqv, + Expr{Constant{element}}, Expr{Constant{*value}}}})); } else { // compare array(at) to value - cmp.emplace( - PackageRelation(relation, Expr{Constant{std::move(element)}}, - Expr{Constant{*value}})); + cmp.emplace(PackageRelation(relation, Expr{Constant{element}}, + Expr{Constant{*value}})); } Expr folded{Fold(context_, std::move(*cmp))}; result = GetScalarConstantValue(folded).value().IsTrue(); diff --git a/flang/test/Evaluate/fold-findloc.f90 b/flang/test/Evaluate/fold-findloc.f90 --- a/flang/test/Evaluate/fold-findloc.f90 +++ b/flang/test/Evaluate/fold-findloc.f90 @@ -60,4 +60,10 @@ logical, parameter :: test_xi3b = all(maxloc(ia3, back=.true.) == [0,0,0]) logical, parameter :: test_xi3c = all(maxloc(ia3, dim=2) == reshape([0,0,0,0],shape=[2,2])) logical, parameter :: test_xi3d = all(maxloc(ia3, dim=2, back=.true.) == reshape([0,0,0,0],shape=[2,2])) + + character(1), parameter :: a(4) = ['a', 'b', 'a', 'b'] + logical, parameter :: test_char1 = all(maxloc(a).eq.[2]) + logical, parameter :: test_char2 = all(minloc(a).eq.[1]) + logical, parameter :: test_char3 = all(maxloc(a, back=.true.).eq.[4]) + logical, parameter :: test_char4 = all(minloc(a, back=.true.).eq.[3]) end module