From 7b9518ae277d48b733bbd542dbe9f3388f5ceee1 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Wed, 4 Jun 2025 09:22:01 -0700 Subject: [PATCH] [flang][runtime] Accommodate change of type in assignment to allocatable (#141988) When an assignment to a derived type allocatable requires (re)allocation, its type may change to that of the right-hand side. The code didn't update its derived type pointer, leading to the wrong type being put into the descriptors created for elemental defined assignment subroutine calls. Fixes https://github.com/llvm/llvm-project/issues/141835. --- flang-rt/lib/runtime/assign.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/flang-rt/lib/runtime/assign.cpp b/flang-rt/lib/runtime/assign.cpp index 86aeeaa88f2d..bf67b5dc8b64 100644 --- a/flang-rt/lib/runtime/assign.cpp +++ b/flang-rt/lib/runtime/assign.cpp @@ -330,6 +330,7 @@ RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from, } flags &= ~NeedFinalization; toElementBytes = to.ElementBytes(); // may have changed + toDerived = toAddendum ? toAddendum->derivedType() : nullptr; } } if (toDerived && (flags & CanBeDefinedAssignment)) {