[llvm] [flang] Don't associate pointers with zero sized storage targets (PR #155867)
Eugene Epshteyn via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 28 08:55:59 PDT 2025
https://github.com/eugeneepshteyn created https://github.com/llvm/llvm-project/pull/155867
Fixes #155481
>From 96e80af46f4cba147b3c3297cdcc138ffcafb775 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Thu, 28 Aug 2025 11:54:13 -0400
Subject: [PATCH] [flang] Don't associate pointers with zero sized storage
targets
Fixes #155481
---
flang-rt/lib/runtime/pointer.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/flang-rt/lib/runtime/pointer.cpp b/flang-rt/lib/runtime/pointer.cpp
index 68db2594acdd4..4b1b921b1ce07 100644
--- a/flang-rt/lib/runtime/pointer.cpp
+++ b/flang-rt/lib/runtime/pointer.cpp
@@ -67,8 +67,12 @@ void RTDEF(PointerAssociateScalar)(Descriptor &pointer, void *target) {
}
void RTDEF(PointerAssociate)(Descriptor &pointer, const Descriptor &target) {
- pointer = target;
- pointer.raw().attribute = CFI_attribute_pointer;
+ if (target.ElementBytes() > 0) {
+ // F2023, 16.9.20, p5, case (v)-(vi): don't associate pointers with
+ // targets that have zero sized storage sequence.
+ pointer = target;
+ pointer.raw().attribute = CFI_attribute_pointer;
+ }
}
void RTDEF(PointerAssociateLowerBounds)(Descriptor &pointer,
More information about the llvm-commits
mailing list