diff --git a/flang/runtime/allocatable.cpp b/flang/runtime/allocatable.cpp --- a/flang/runtime/allocatable.cpp +++ b/flang/runtime/allocatable.cpp @@ -94,6 +94,13 @@ descriptor.set_base_addr(nullptr); descriptor.raw().attribute = CFI_attribute_allocatable; descriptor.raw().rank = rank; + if (auto *descAddendum{descriptor.Addendum()}) { + if (const auto *moldAddendum{mold.Addendum()}) { + if (const auto *derived{moldAddendum->derivedType()}) { + descAddendum->set_derivedType(derived); + } + } + } } int RTNAME(AllocatableAllocate)(Descriptor &descriptor, bool hasStat, diff --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp --- a/flang/runtime/pointer.cpp +++ b/flang/runtime/pointer.cpp @@ -60,6 +60,13 @@ pointer.set_base_addr(nullptr); pointer.raw().attribute = CFI_attribute_pointer; pointer.raw().rank = rank; + if (auto *pointerAddendum{pointer.Addendum()}) { + if (const auto *moldAddendum{mold.Addendum()}) { + if (const auto *derived{moldAddendum->derivedType()}) { + pointerAddendum->set_derivedType(derived); + } + } + } } void RTNAME(PointerAssociateScalar)(Descriptor &pointer, void *target) {