-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[libc++] Workaround for a bug of overloads in MS UCRT's <math.h>
#149234
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,6 +427,23 @@ using std::__math::islessgreater; | |
using std::__math::isnan; | ||
using std::__math::isnormal; | ||
using std::__math::isunordered; | ||
# elif _LIBCPP_STD_VER >= 20 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor nit, but I would find this code block easier to read if we did this instead:
When looking at the code quickly, a stray Just a suggestion, not a requirement. |
||
// MS UCRT incorrectly defines some functions in a way not working with integer types. Until C++20, this was worked | ||
// around by -fdelayed-template-parsing. Since C++20, we can use standard feature "requires" instead. | ||
|
||
// TODO: Remove the workaround once UCRT fixes these functions. Note that this doesn't seem planned as of 2025-07 per | ||
// https://developercommunity.visualstudio.com/t/10294165. | ||
|
||
using std::__math::__ucrt::isfinite; | ||
using std::__math::__ucrt::isgreater; | ||
using std::__math::__ucrt::isgreaterequal; | ||
using std::__math::__ucrt::isinf; | ||
using std::__math::__ucrt::isless; | ||
using std::__math::__ucrt::islessequal; | ||
using std::__math::__ucrt::islessgreater; | ||
using std::__math::__ucrt::isnan; | ||
using std::__math::__ucrt::isnormal; | ||
using std::__math::__ucrt::isunordered; | ||
# endif // _LIBCPP_MSVCRT | ||
|
||
// We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StephanTLavavej Do you think there is any way we might be able to get a fix in UCRT for this?
@frederick-vs-ja Since this is a bug in UCRT which has been reported and closed as "not to be fixed", I am tempted to say that keeping these tests as
XFAIL
and being non-conforming on UCRT might be acceptable. If they don't think it's worth fixing the issue, I'm not sure it's worth us doing a (pretty involved) workaround for it either.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've brought this up to the UCRT team since we're (very likely) going to have to alter math.h for constexpr cmath, and it would be nice to have a set of changes that fixes everything once and for all.
That said, I would not hold my breath expecting this to change any time soon. MSVC's STL also has workarounds for the UCRT issues here.