[flang] Don't associate pointers with zero sized storage targets (#155867)
Fixes #155481
diff --git a/flang-rt/lib/runtime/pointer.cpp b/flang-rt/lib/runtime/pointer.cpp
index 68db259..f8ada65 100644
--- a/flang-rt/lib/runtime/pointer.cpp
+++ b/flang-rt/lib/runtime/pointer.cpp
@@ -267,8 +267,10 @@
   if (!target) {
     return pointer.raw().base_addr != nullptr;
   }
-  if (!target->raw().base_addr ||
-      (target->raw().type != CFI_type_struct && target->ElementBytes() == 0)) {
+  if (!target->raw().base_addr || target->ElementBytes() == 0 ||
+      target->Elements() == 0) {
+    // F2023, 16.9.20, p5, case (v)-(vi): don't associate pointers with
+    // targets that have zero sized storage sequence.
     return false;
   }
   int rank{pointer.rank()};