diff --git a/flang/runtime/derived.cpp b/flang/runtime/derived.cpp --- a/flang/runtime/derived.cpp +++ b/flang/runtime/derived.cpp @@ -231,8 +231,9 @@ if (comp.genre() == typeInfo::Component::Genre::Allocatable || comp.genre() == typeInfo::Component::Genre::Automatic) { for (std::size_t j{0}; j < elements; ++j) { - descriptor.OffsetElement(j * byteStride + comp.offset()) - ->Deallocate(); + Descriptor *d{reinterpret_cast( + descriptor.ZeroBasedIndexedElement(j) + comp.offset())}; + d->Deallocate(); } } }