<cmath>: Support /Zc:cmath downlevel - #6425
Merged
Stephan T. Lavavej (StephanTLavavej) merged 3 commits intoSep 3, 2026
Merged
Stephan T. Lavavej (StephanTLavavej) merged 3 commits into
Stephan T. Lavavej (StephanTLavavej) merged 3 commits into
Conversation
Stephan T. Lavavej (StephanTLavavej)
requested a review
from a team
as a code owner
August 31, 2026 19:23
This comment was marked as resolved.
This comment was marked as resolved.
Copilot started reviewing on behalf of
Stephan T. Lavavej (StephanTLavavej)
August 31, 2026 19:24
View session
Contributor
|
Will this resolve the performance issue in #4998? |
Member
Author
|
Yes, I think so. However, I haven't looked at the codegen. |
Member
Author
|
I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required. |
David Justo (davidmrdavid)
approved these changes
Sep 3, 2026
David Justo (davidmrdavid)
self-requested a review
September 3, 2026 14:53
David Justo (davidmrdavid)
left a comment
Member
There was a problem hiding this comment.
Before approving, I have some questions about downstream effects. I'll confirm some thing internally :-]
David Justo (davidmrdavid)
approved these changes
Sep 3, 2026
Stephan T. Lavavej (StephanTLavavej)
merged commit Sep 3, 2026
bcf405a
into
microsoft:main
48 checks passed
Charlie Lin (clin1234)
pushed a commit
to clin1234/STL
that referenced
this pull request
Sep 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Followup to #6413. Cody Miller (@Codiferous) noticed that while MSVC supports
/Zc:cmathdownlevel (i.e. in C++14/17/20 before C++23) and rewrites<math.h>to<__msvc_math.hpp>which always uses builtins, our<cmath>used/Zc:cmathbuiltins only in C++23 mode. In downlevel modes, it fell back to intrinsics, which created conflicts between libc math and UCRT math.The fix is to generalize
<cmath>to use builtins when they're available under/Zc:cmathregardless of Standard mode. Marking our functions asconstexpris still controlled by the Standard mode.This PR then significantly enhances test coverage to cover downlevel modes. This is the first time that our test suite explicitly acknowledges the difference between
/std:c++23previewand/std:c++latest, which I will be introducing at a larger scale later.