[flang] prevent undefined behavior in character MAXLOC folding
When folding MAXLOC/MINLOC, the current element being compared was moved twice in row in case it became the new extremum. With numeric and logical types, it made no difference (std::move is a no-op for them), but for characters where the string storage is actually moved, it caused the new extremum to be set to the empty string, leading to wrong results. Note: I could have left the first std::move relating to logical Findloc, but it brings nothing and makes the code less auditable, so I also removed it. Differential Revision: https://reviews.llvm.org/D122590
Loading
Please sign in to comment