Skip to content

🍒[cxx-interop] Avoid linker errors when calling a defaulted constructor #66595

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
Jun 14, 2023

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Jun 13, 2023

Explanation: When a default constructor is declared, but does not have a body because it is defaulted (= default;), Swift did not emit the IR for it. This was causing linker error for types such as std::map in libstdc++ when someone tried to initialize such types from Swift.
Scope: This adjusts the way default constructors are imported for C++ structs.
Risk: Low, this only has an effect when C++ interop is enabled.

rdar://110638499 / resolves #61412 (cherry picked from commit b459fb5)

When a default constructor is declared, but does not have a body because it is defaulted (`= default;`), Swift did not emit the IR for it. This was causing linker error for types such as `std::map` in libstdc++ when someone tried to initialize such types from Swift.

rdar://110638499 / resolves #61412
(cherry picked from commit b459fb5)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jun 13, 2023
@egorzhdan egorzhdan requested a review from a team as a code owner June 13, 2023 12:44
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test macOS

@egorzhdan egorzhdan merged commit a9df9e6 into release/5.9 Jun 14, 2023
@egorzhdan egorzhdan deleted the egorzhdan/5.9-irgen-defaulted-constructor branch June 14, 2023 11:42
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++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants