diff --git a/flang/runtime/assign.cpp b/flang/runtime/assign.cpp index 9e10e2f491ed2..f75fe94bf3009 100644 --- a/flang/runtime/assign.cpp +++ b/flang/runtime/assign.cpp @@ -294,6 +294,10 @@ static void Assign( StaticDescriptor staticDesc; Descriptor &newFrom{staticDesc.descriptor()}; std::memcpy(&newFrom, &from, descBytes); + // Pretend the temporary descriptor is for an ALLOCATABLE + // entity, otherwise, the Deallocate() below will not + // free the descriptor memory. + newFrom.raw().attribute = CFI_attribute_allocatable; auto stat{ReturnError(terminator, newFrom.Allocate())}; if (stat == StatOk) { char *toAt{newFrom.OffsetElement()};