[flang-commits] [flang] [flang] Set the offset based on the significant bytes in the boz input in big endian (PR #102334)
    via flang-commits 
    flang-commits at lists.llvm.org
       
    Wed Aug  7 10:22:00 PDT 2024
    
    
  
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-runtime
Author: Kelvin Li (kkwli)
<details>
<summary>Changes</summary>
The offset to the input data should be counted from most significant bit instead of zero in the big endian environment.
---
Full diff: https://github.com/llvm/llvm-project/pull/102334.diff
1 Files Affected:
- (modified) flang/runtime/edit-input.cpp (+1-1) 
``````````diff
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)};
``````````
</details>
https://github.com/llvm/llvm-project/pull/102334
    
    
More information about the flang-commits
mailing list