diff --git a/flang/runtime/type-info.h b/flang/runtime/type-info.h --- a/flang/runtime/type-info.h +++ b/flang/runtime/type-info.h @@ -38,7 +38,7 @@ Explicit = 2, LenParameter = 3 }; - + Genre genre() const { return genre_; } std::optional GetValue(const Descriptor *) const; private: diff --git a/flang/runtime/type-info.cpp b/flang/runtime/type-info.cpp --- a/flang/runtime/type-info.cpp +++ b/flang/runtime/type-info.cpp @@ -89,9 +89,14 @@ const Descriptor &container, Terminator &terminator) const { TypeCategory cat{category()}; if (cat == TypeCategory::Character) { - auto length{characterLen_.GetValue(&container)}; - RUNTIME_CHECK(terminator, length.has_value()); - descriptor.Establish(kind_, *length / kind_, nullptr, rank_); + std::size_t lengthInChars{0}; + if (auto length{characterLen_.GetValue(&container)}) { + lengthInChars = static_cast(*length / kind_); + } else { + RUNTIME_CHECK( + terminator, characterLen_.genre() == Value::Genre::Deferred); + } + descriptor.Establish(kind_, lengthInChars, nullptr, rank_); } else if (cat == TypeCategory::Derived) { const DerivedType *type{derivedType()}; RUNTIME_CHECK(terminator, type != nullptr);