[flang-commits] [flang] [Flang] Shift the data from lower to higher order bits in the big endian environment (PR #73670)

via flang-commits flang-commits at lists.llvm.org
Mon Dec 18 19:16:25 PST 2023


================
@@ -244,7 +244,15 @@ bool EditIntegerInput(
     value = -value;
   }
   if (any || !io.GetConnectionState().IsAtEOF()) {
-    std::memcpy(n, &value, kind); // a blank field means zero
+    // The value is stored in the lower order bits on big endian platform.
+    // When memcpy, shift the value to the higher order bit.
+    auto shft{static_cast<int>(sizeof(value.low())) - kind};
+    if (!isHostLittleEndian && shft >= 0) {
----------------
kkwli wrote:

We still need `shft==0` case. It is when `kind==8`, the value is still stored in `low_`.

https://github.com/llvm/llvm-project/pull/73670


More information about the flang-commits mailing list