From 72144d119a7291f8b6b8e022a2947fbe31e66afc Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Fri, 11 Apr 2025 12:52:23 -0700 Subject: [PATCH] [flang][runtime] Fix recently broken big-endian formatted integer input (#135417) My recent change to speed up formatted integer input has a bug on big-endian targets that has shown up on ppc64 AIX build bots. Fix. --- flang-rt/lib/runtime/edit-input.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flang-rt/lib/runtime/edit-input.cpp b/flang-rt/lib/runtime/edit-input.cpp index 0a7b09f836c7..4aa8c70f776c 100644 --- a/flang-rt/lib/runtime/edit-input.cpp +++ b/flang-rt/lib/runtime/edit-input.cpp @@ -293,8 +293,8 @@ RT_API_ATTRS bool EditIntegerInput(IoStatementState &io, const DataEdit &edit, #if USING_NATIVE_INT128_T auto shft{static_cast(sizeof value - kind)}; if (!isHostLittleEndian && shft >= 0) { - auto l{value << shft}; - std::memcpy(n, &l, kind); + auto shifted{value << (8 * shft)}; + std::memcpy(n, &shifted, kind); } else { std::memcpy(n, &value, kind); // a blank field means zero }