[llvm] [flang][flang-rt] Fix abort on intrinsic assignment from ZLA (PR #177195)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 21 08:29:29 PST 2026


https://github.com/tmjbios created https://github.com/llvm/llvm-project/pull/177195

Intrinsic assignment from a zero-length character array should result in the destination being blank-padded to its length (10.2.1.3).

>From e14478257349f51e7c5d3e243198d485c2040def Mon Sep 17 00:00:00 2001
From: Ted Johnson <tedmjohnson at protonmail.com>
Date: Tue, 6 Jan 2026 17:05:07 -0600
Subject: [PATCH] [flang][flang-rt] Address crash on intrinsic assignment from
 ZLA

Intrinsic assignment from a zero-length character array should
result in the destination being blank-padded (10.2.1.3).

Test for this change is in llvm-test-suite.
---
 flang-rt/lib/runtime/assign.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang-rt/lib/runtime/assign.cpp b/flang-rt/lib/runtime/assign.cpp
index dd5d4b945881e..4d7c97e86e30a 100644
--- a/flang-rt/lib/runtime/assign.cpp
+++ b/flang-rt/lib/runtime/assign.cpp
@@ -451,7 +451,7 @@ RT_API_ATTRS int AssignTicket::Continue(WorkQueue &workQueue) {
   std::size_t toElements{to_.InlineElements()};
   if (from_->rank() > 0) {
     std::size_t fromElements{from_->InlineElements()};
-    if (toElements != fromElements) {
+    if (fromElements && toElements != fromElements) {
       workQueue.terminator().Crash("Assign: mismatching element counts in "
                                    "array assignment (to %zd, from %zd)",
           toElements, fromElements);



More information about the llvm-commits mailing list