diff --git a/flang/runtime/derived.cpp b/flang/runtime/derived.cpp index bb47f6b7a3292..05c5b5264b9d4 100644 --- a/flang/runtime/derived.cpp +++ b/flang/runtime/derived.cpp @@ -48,7 +48,7 @@ int Initialize(const Descriptor &instance, const typeInfo::DerivedType &derived, // non-allocatable non-automatic components std::size_t bytes{comp.SizeInBytes(instance)}; for (std::size_t j{0}; j < elements; ++j) { - char *ptr{instance.OffsetElement(j * byteStride + comp.offset())}; + char *ptr{instance.ZeroBasedIndexedElement(j) + comp.offset()}; std::memcpy(ptr, init, bytes); } } else if (comp.genre() == typeInfo::Component::Genre::Data &&