Skip to content

5.10: [interop][SwiftToCxx] consuming parameters should be passed using an additional copy #69522

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 5 commits into from
Oct 31, 2023

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Oct 30, 2023

Fixes #69372

rdar://117431113

  • Explanation:
    C++ inline thunks that were generated in the generated header didn't account for the consuming parameter convention correctly. This change fixes that by introducing an extra copy of the passed-in parameter, to ensure that Swift's owned destroy / release of the consumed value is correctly balanced.
    This covers consumption of both Swift types and C++ types (copyable).
    Note that additionally this change no longer exposes the shared C++ reference types from Swift back to C++, as their ownership semantics are not yet well specified at the point of the C++ -> Swift language boundary. We'll be able to support better shared reference model in the future though so for now disabling this is safer.
  • Scope: C++ interop, generated header generator
  • Risk: Low, this is already broken and needs to be fixed. Only touches on explicit consuming parameters, or implicit ones like for the initializers and setters
  • Testing: Unit tests, manual sample project testing
  • Original PR: [interop][SwiftToCxx] consuming parameters should be passed using an … #69473

@hyp hyp added c++ interop Feature: Interoperability with C++ swift 5.10 labels Oct 30, 2023
@hyp hyp requested a review from a team as a code owner October 30, 2023 22:34
@hyp
Copy link
Contributor Author

hyp commented Oct 30, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Oct 30, 2023

@swift-ci please test source compatibility

@hyp hyp merged commit f93de71 into swiftlang:release/5.10 Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++ swift 5.10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants