[flang-commits] [flang] [flang] Set the offset based on the significant bytes in the boz input in big endian (PR #102334)

Kelvin Li via flang-commits flang-commits at lists.llvm.org
Wed Aug 7 10:21:27 PDT 2024


https://github.com/kkwli created https://github.com/llvm/llvm-project/pull/102334

The offset to the input data should be counted from most significant bit instead of zero in the big endian environment.

>From 8487a7fbc5ea157edb4a6756e9defac040524aff Mon Sep 17 00:00:00 2001
From: Kelvin Li <kli at ca.ibm.com>
Date: Wed, 7 Aug 2024 13:09:41 -0400
Subject: [PATCH] [flang] Set the offset based on the significant bytes in the
 boz input in big endian

---
 flang/runtime/edit-input.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index 37989bbcee0ab..71021dd8a0158 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -119,7 +119,7 @@ static RT_API_ATTRS bool EditBOZInput(
   std::memset(n, 0, bytes);
   int increment{isHostLittleEndian ? -1 : 1};
   auto *data{reinterpret_cast<unsigned char *>(n) +
-      (isHostLittleEndian ? significantBytes - 1 : 0)};
+      (isHostLittleEndian ? significantBytes - 1 : bytes - significantBytes)};
   int shift{((digits - 1) * LOG2_BASE) & 7};
   while (digits > 0) {
     char32_t ch{*io.NextInField(remaining, edit)};



More information about the flang-commits mailing list