-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Strengthen exception specification for numeric operations #3887
Strengthen exception specification for numeric operations #3887
Conversation
Adding unconditional `noexcept` to suitable functions in `<cmath>`, `<random>`, and `<valarray>`. Currently only test for `<valarray>` is added.
I'm questioning |
If we can't detect this statically, I doubt it's a supportable configuration. |
I don't agree. I think not putting excaption specification is enough to support that config |
The configuration sounds like a non-conforming extension, and is heavily broken due to MSVC's default |
Tested on acb8d34:
#include <cmath>
#include <cstdio>
#include <float.h>
#include <format>
#include <optional>
using namespace std;
#pragma fenv_access(on)
int main() {
optional<double> result{};
puts(format("noexcept(result = hypot(1.0, 2.0, 3.0)) == {:s}", noexcept(result = hypot(1.0, 2.0, 3.0))).c_str());
_controlfp(0, _MCW_EM);
try {
result = hypot(1.0, 2.0, 3.0);
} catch (...) {
puts("exception caught");
}
_controlfp(_CW_DEFAULT, _MCW_EM);
if (result) {
puts(format("result = {}", *result).c_str());
} else {
puts("result = (nullopt)");
}
return 0;
}
|
Not exactly the case I had in mind. I meant |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
🦾
|
Adding unconditional
noexcept
to suitable functions in<cmath>
,<random>
, and<valarray>
.(Conditional
noexcept
may be suitable for many functions in<random>
...)Currently only test for
<valarray>
is added. I hope we can add the test coverage to a new test suit for MS-specific properties and extensions in the future (see #502).A bug of MSVC (DevCom-10416247) is discovered during testing.