Skip to content

Remove constexpr-if from runtime #40865

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
Jan 15, 2022

Conversation

etcwilde
Copy link
Member

constexpr-if is a C++17 feature. Swift is C++14, so this results in a
lot of warnings. Clang is smart enough that the constant propagation
will elide the unused side of the branch anyway. Since we're doing a
template check on a type, we should always have enough information at
compile to elide. We would need a constexpr/std::enable_if-level
approach if the API's were different to tell clang not to look at one
side of the branch. That's not the case here so we can let the optimizer
do it's thing and let clang look at both sides.

constexpr-if is a C++17 feature. Swift is C++14, so this results in a
lot of warnings. Clang is smart enough that the constant propagation
will elide the unused side of the branch anyway. Since we're doing a
template check on a type, we should always have enough information at
compile to elide. We would need a constexpr/std::enable_if-level
approach if the API's were different to tell clang not to look at one
side of the branch. That's not the case here so we can let the optimizer
do it's thing and let clang look at both sides.
@etcwilde etcwilde requested a review from grynspan January 15, 2022 00:22
@etcwilde
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d452f68

@etcwilde
Copy link
Member Author

@swift-ci please clean test Linux

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d452f68

@etcwilde
Copy link
Member Author

MacOS failure:

ERROR: Your system does not have a 32-bit watchOS simulator installed.
INFO: 1. Install watchOS 6.2.1 simulator (Xcode -> Preferences -> Components -> Simulators).
INFO: 2. Create a 32-bit watchOS device. Run:
INFO:    $ xcrun simctl create 'Apple Watch Series 2 - 42mm' com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm com.apple.CoreSimulator.SimRuntime.watchOS-6-2

@etcwilde
Copy link
Member Author

@swift-ci please test macOS

@etcwilde etcwilde merged commit d89a524 into swiftlang:main Jan 15, 2022
@etcwilde etcwilde deleted the ewilde/remove-constexpr-if branch January 15, 2022 23:05
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.

2 participants