Skip to content

Commit 3ddfb68

Browse files
authored
[flang] Prevent crash from unfoldable TRANSFER() (llvm#92282)
When the MOLD= argument's type is polymorphic, the type of the result cannot be known at compilation time, so the call cannot be folded even when the SOURCE= is constant. Fixes llvm#92264.
1 parent 5bbb63b commit 3ddfb68

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

flang/lib/Evaluate/fold.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ std::optional<Expr<SomeType>> FoldTransfer(
272272
}
273273
}
274274
if (sourceBytes && IsActuallyConstant(*source) && moldType && extents &&
275+
!moldType->IsPolymorphic() &&
275276
(moldLength || moldType->category() != TypeCategory::Character)) {
276277
std::size_t elements{
277278
extents->empty() ? 1 : static_cast<std::size_t>((*extents)[0])};

0 commit comments

Comments
 (0)