Skip to content

Fix warning C4702 emitted from format.h (MSVC) - #3866

Merged
vitaut merged 1 commit into
fmtlib:masterfrom
Baardi:unreachable-code
Feb 28, 2024
Merged

vitaut merged 1 commit into
fmtlib:masterfrom
Baardi:unreachable-code

Conversation

@Baardi

@Baardi Baardi commented Feb 24, 2024

Copy link
Copy Markdown
Contributor

Compiler: MSVC, Windows x64, Visual Studio 17.9.1
C++ standard: Any (recreatable with anything from c++14 to c++latest)
Fmtlib version: Master branch
Warning level: /W4 or higher

Hi. This is a new warning, not emitted when using the 10.2.1-release, but recreatable from the master branch.

It can easily be recreated by the following lines of code:

#define FMT_HEADER_ONLY
#include <fmt/format.h>

void test()
{
   fmt::println("test");
}

bilde

It seems that the default-label in the switch-case prevents execution from reaching the bottom of the function. MSVC therefore emits a warning. I haven't tested this on other platforms

@vitaut
vitaut merged commit ae1e93d into fmtlib:master Feb 28, 2024
@vitaut

vitaut commented Feb 28, 2024

Copy link
Copy Markdown
Contributor

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants