-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Silence unreachable code warnings in MSVC when FMT_USE_EXCEPTIONS are… #4515
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
Conversation
Please post the full warning. |
volatile bool b = true; | ||
if (b) { |
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 wonder if this can be
if (const_check(true)) {
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.
Tried this version and it unfortunately doesn't stop the warnings:
FMT_FUNC void report_error(const char* message) {
#if FMT_USE_EXCEPTIONS
// Use FMT_THROW instead of throw to avoid bogus unreachable code warnings
// from MSVC.
FMT_THROW(format_error(message));
#else
if (detail::const_check(true)) {
fputs(message, stderr);
abort();
}
#endif
}
Basically every
|
Could you provide a gobolt repro? I tried to repro in https://www.godbolt.org/z/Mjb6xY4vT but to no avail. |
It seems to only trigger in release mode, and with /W4 /O2 |
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.
In general we only care about /W3 but I guess this one is trivial to fix so let's merge.
Merged, thanks. |
Removes warnings about unreachable code in VS 2022, 17.14.12 when exceptions are disabled.