Skip to content

[ClangImporter] Fix dangling reference. #82708

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
Jul 4, 2025

Conversation

Bigcheese
Copy link
Contributor

LookupOverloadedBinOp stores Args for later use, so store the backing array on the stack instead of using a temporary.

This fixes a crash that appears under some build configurations.

Related to rdar://154291418

LookupOverloadedBinOp stores `Args` for later use, so store the
backing array on the stack instead of using a temporary.

This fixes a crash that appeared under some build configurations.

Related to rdar://154291418
@Bigcheese
Copy link
Contributor Author

@swift-ci please test

@AnthonyLatsis
Copy link
Collaborator

@swift-ci please test Windows

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@@ -265,7 +265,8 @@ instantiateTemplatedOperator(ClangImporter::Implementation &impl,
classDecl->getLocation(), clang::OverloadCandidateSet::CSK_Operator,
clang::OverloadCandidateSet::OperatorRewriteInfo(opKind,
clang::SourceLocation(), false));
clangSema.LookupOverloadedBinOp(candidateSet, opKind, ops, {arg, arg}, true);
std::array<clang::Expr *, 2> args{arg, arg};
clangSema.LookupOverloadedBinOp(candidateSet, opKind, ops, args, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on where this array gets stored and for how long? Are we storing the array in the candidateSet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's stored in candidateSet so the lifetime needs to extend to the last use of candidateSet, excluding the destructor.

@Bigcheese
Copy link
Contributor Author

@swift-ci please test windows

@bnbarham
Copy link
Contributor

bnbarham commented Jul 3, 2025

@swift-ci please test Windows platform

2 similar comments
@Bigcheese
Copy link
Contributor Author

@swift-ci please test Windows platform

@bnbarham
Copy link
Contributor

bnbarham commented Jul 3, 2025

@swift-ci please test Windows platform

@bnbarham
Copy link
Contributor

bnbarham commented Jul 4, 2025

@swift-ci please test Windows

@bnbarham bnbarham merged commit d9b220c into swiftlang:main Jul 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants