Skip to content

[flang] Prevent crash from unfoldable TRANSFER() #92282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2024
Merged

Conversation

klausler
Copy link
Contributor

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 #92264.

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.
@llvmbot
Copy link
Member

llvmbot commented May 15, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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 #92264.


Full diff: https://github.com/llvm/llvm-project/pull/92282.diff

1 Files Affected:

  • (modified) flang/lib/Evaluate/fold.cpp (+1)
diff --git a/flang/lib/Evaluate/fold.cpp b/flang/lib/Evaluate/fold.cpp
index ed88295819980..cf6262d9a7c65 100644
--- a/flang/lib/Evaluate/fold.cpp
+++ b/flang/lib/Evaluate/fold.cpp
@@ -272,6 +272,7 @@ std::optional<Expr<SomeType>> FoldTransfer(
     }
   }
   if (sourceBytes && IsActuallyConstant(*source) && moldType && extents &&
+      !moldType->IsPolymorphic() &&
       (moldLength || moldType->category() != TypeCategory::Character)) {
     std::size_t elements{
         extents->empty() ? 1 : static_cast<std::size_t>((*extents)[0])};

@klausler klausler merged commit 3ddfb68 into llvm:main May 15, 2024
6 of 7 checks passed
@klausler klausler deleted the bug92264 branch May 15, 2024 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Flang] fatal internal error: CHECK(!type.IsPolymorphic()) failed at /root/llvm-project/flang/lib/Evaluate/initial-image.cpp(83)
3 participants