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

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Tue Dec 12 16:08:19 PST 2023


================
@@ -222,7 +222,15 @@ bool EditIntegerInput(
     value = -value;
   }
   if (any || !io.GetConnectionState().IsAtEOF()) {
-    std::memcpy(n, &value, kind); // a blank field means zero
+    // For integer kind <= 4, the value is stored in the lower order bits on
----------------
klausler wrote:

> If the 128-bit input, the full 128-bit will be copied.

Yes, that's my concern.  If the source of the copy is an instantiation of Fortran::common::Int128, the low half always comes first, so it can't just be copied into a Fortran `INTEGER(16)`.  Any built-in C++ 128-bit integer type is fine, but not Int128.  So maybe you want to modify Int128 to reflect host endianness so that it will work if it's being used in the runtime.

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


More information about the flang-commits mailing list