From f45b6f1749fb58c7e4e956972f0ce9bb92246f15 Mon Sep 17 00:00:00 2001 From: soniafergusonship Date: Thu, 13 Aug 2026 21:27:31 +0800 Subject: [PATCH] fix(msvc): silence C4702 unreachable warnings in value parser (#307) Signed-off-by: soniafergusonship --- include/toml++/impl/parser.inl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/toml++/impl/parser.inl b/include/toml++/impl/parser.inl index 7d483763..bbf0633b 100644 --- a/include/toml++/impl/parser.inl +++ b/include/toml++/impl/parser.inl @@ -2772,7 +2772,8 @@ TOML_IMPL_NAMESPACE_START // now things that can be identified from two or more characters return_if_error({}); - TOML_ASSERT_ASSUME(char_count >= 2u); + if (char_count < 2u) + set_error_and_return_default("could not determine value type"sv); // do some 'fuzzy matching' where there's no ambiguity, since that allows the specific // typed parse functions to take over and show better diagnostics if there's an issue @@ -2833,6 +2834,10 @@ TOML_IMPL_NAMESPACE_START // all correct value parses will come out of this list, so doing this as a switch is likely to // be a better friend to the optimizer on the success path (failure path can be slow but that // doesn't matter much). +#if TOML_MSVC +#pragma warning(push) +#pragma warning(disable : 4702) // unreachable code (false-positive from trait bitmask switch) +#endif switch (unwrap_enum(traits)) { // binary integers