[flang-commits] [flang] [flang][runtime] Fix namelist substring checking (PR #78649)
via flang-commits
flang-commits at lists.llvm.org
Thu Jan 18 16:16:49 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-runtime
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
An || operator in namelist substring bounds checking really needs to be an && operator so that the substring is viewed as correct only when both its bounds are valid.
Fixes llvm-test-suite/Fortran/gfortran/regression/namelist_40.f90.
---
Full diff: https://github.com/llvm/llvm-project/pull/78649.diff
1 Files Affected:
- (modified) flang/runtime/namelist.cpp (+1-1)
``````````diff
diff --git a/flang/runtime/namelist.cpp b/flang/runtime/namelist.cpp
index 848ebcf300a3d9..f5d7404fdcb86b 100644
--- a/flang/runtime/namelist.cpp
+++ b/flang/runtime/namelist.cpp
@@ -313,7 +313,7 @@ static bool HandleSubstring(
desc.raw().elem_len = 0;
return true;
}
- if (*lower >= 1 || *upper <= chars) {
+ if (*lower >= 1 && *upper <= chars) {
// Offset the base address & adjust the element byte length
desc.raw().elem_len = (*upper - *lower + 1) * kind;
desc.set_base_addr(reinterpret_cast<void *>(
``````````
</details>
https://github.com/llvm/llvm-project/pull/78649
More information about the flang-commits
mailing list