Silence unreachable code warnings in MSVC when FMT_USE_EXCEPTIONS are…#4515
Merged
vitaut merged 1 commit intofmtlib:masterfrom Aug 17, 2025
Merged
Silence unreachable code warnings in MSVC when FMT_USE_EXCEPTIONS are…#4515vitaut merged 1 commit intofmtlib:masterfrom
vitaut merged 1 commit intofmtlib:masterfrom
Conversation
Contributor
|
Please post the full warning. |
vitaut
reviewed
Aug 14, 2025
Comment on lines
+142
to
+143
| volatile bool b = true; | ||
| if (b) { |
Contributor
There was a problem hiding this comment.
I wonder if this can be
if (const_check(true)) {
Contributor
Author
There was a problem hiding this comment.
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
}
Contributor
Author
Basically every |
Contributor
|
Could you provide a gobolt repro? I tried to repro in https://www.godbolt.org/z/Mjb6xY4vT but to no avail. |
Contributor
Author
It seems to only trigger in release mode, and with /W4 /O2 |
vitaut
approved these changes
Aug 17, 2025
Contributor
vitaut
left a comment
There was a problem hiding this comment.
In general we only care about /W3 but I guess this one is trivial to fix so let's merge.
Contributor
|
Merged, thanks. |
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.
Removes warnings about unreachable code in VS 2022, 17.14.12 when exceptions are disabled.