diff --git a/flang/runtime/allocatable.cpp b/flang/runtime/allocatable.cpp --- a/flang/runtime/allocatable.cpp +++ b/flang/runtime/allocatable.cpp @@ -140,8 +140,15 @@ descriptor, hasStat, errMsg, sourceFile, sourceLine)}; if (stat == StatOk) { DescriptorAddendum *addendum{descriptor.Addendum()}; - INTERNAL_CHECK(addendum != nullptr); - addendum->set_derivedType(derivedType); + if (addendum) { // Unlimited polymorphic allocated from intrinsic type spec + // does not have + addendum->set_derivedType(derivedType); + } else { + // Unlimited polymorphic descriptors initialized with + // AllocatableInitIntrinsic do not have an addendum. Make sure the + // derivedType is null in that case. + INTERNAL_CHECK(!derivedType); + } } return stat; } diff --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp --- a/flang/runtime/pointer.cpp +++ b/flang/runtime/pointer.cpp @@ -181,8 +181,14 @@ pointer, hasStat, errMsg, sourceFile, sourceLine)}; if (stat == StatOk) { DescriptorAddendum *addendum{pointer.Addendum()}; - INTERNAL_CHECK(addendum != nullptr); - addendum->set_derivedType(derivedType); + if (addendum) { + addendum->set_derivedType(derivedType); + } else { + // Unlimited polymorphic descriptors initialized with + // PointerNullifyIntrinsic do not have an addendum. Make sure the + // derivedType is null in that case. + INTERNAL_CHECK(!derivedType); + } } return stat; }