Cleanups 2: Exception handling#2674
Conversation
Add _Throw_future_error_v2.
…_time(). We need extra parens for the macro.
strega-nil-ms
left a comment
There was a problem hiding this comment.
LGTM (still weird seeing _Errno meaning "not an errno")
I think this is more agressively achieved by adding |
|
Yeah, if we ever saw a case where the backend decided to inline a |
|
Is |
My understanding is that it is effectively treated as such (I believe I learned this from @BillyONeal) but it isn't necessarily documented that way. |
This comment was marked as outdated.
This comment was marked as outdated.
|
@strega-nil-ms @barcharcraz @CaseyCarter I have changed the exception messages as follows: #include <format>
#include <iostream>
using namespace std;
template <typename... Args>
void try_vformat(Args... args) {
try {
(void) vformat(args...);
} catch (const format_error& e) {
cout << "format_error: " << e.what() << endl;
}
}
int main() {
try_vformat("{:g}", make_format_args('a'));
try_vformat(L"{:g}", make_wformat_args(L'a'));
try_vformat("{:c}", make_format_args(1729));
try_vformat(L"{:c}", make_wformat_args(70'000));
} |
|
Closing and reopening to fix the CLA check. |
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
<future>: Bypass_Throw_future_error,_Rethrow_future_exception._Throw_future_error2()that's more convenient to call directly with afuture_errc, and we can call_STD rethrow_exception()directly.future.cpp: Mark the unused functions as preserved for bincompat. (No redist change.)<chrono>: Add_Throw_nonexistent_local_time(),_Throw_ambiguous_local_time(). We need extra parens for the macro, due to direct-list-init.<format>,<chrono>: Add_Throw_format_error()."charT"to either"char"or"wchar_t"when throwingformat_error.meow_errc _Errnoto_Ec.In addition to following our conventions, these
[[noreturn]]helpers can improve codegen by helping the compiler see that the EH-throwing paths are unlikely, thus separating out their large codegen and allowing the remaining small codegen (for the success path) to be potentially inlined.