[flang-commits] [flang] [flang][runtime] Fix namelist substring checking (PR #78649)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Jan 18 16:17:31 PST 2024
https://github.com/klausler updated https://github.com/llvm/llvm-project/pull/78649
>From e23ba27eee3e9b7648b88048a94f46f18286ef23 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Thu, 18 Jan 2024 16:13:46 -0800
Subject: [PATCH] [flang][runtime] Fix namelist substring checking
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
and .../namelist_47.f90.
---
flang/runtime/namelist.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 *>(
More information about the flang-commits
mailing list