Skip to content

[5.9][interop] avoid importing math functions from the C++ standard library #65498

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 1, 2023

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Apr 28, 2023

They cause ambiguities with math functions from platform's libc

Explanation: The math functions like pow, sin, abs etc. from C++ standard library get imported into Swift when C++ interop is enabled. This causes ambiguities for users when they're already using such math functions from Darwin/GLibc C modules or from Swift's standard library itself. For now let's not import such functions to Swift, using a heuristic that checks if the function is from one of the known libc++/libstdc++ header.
Scope: Swift's and C++ interoperability, Clang importer.
Risk: Low.
Testing: Swift unit tests, and manual testing on some Swift packages.
Reviewer: @ravikandhadai

They cause ambiguities with math functions from platform's libc
@hyp hyp added the c++ interop Feature: Interoperability with C++ label Apr 28, 2023
@hyp hyp requested a review from a team as a code owner April 28, 2023 14:41
@hyp
Copy link
Contributor Author

hyp commented Apr 28, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Apr 28, 2023

@swift-ci please test source compatibility

@hyp hyp merged commit 876ab2a into swiftlang:release/5.9 May 1, 2023
@AnthonyLatsis AnthonyLatsis added the 🍒 release cherry pick Flag: Release branch cherry picks label May 3, 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++ 🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants