From 6f05bffb5fde706e492dd6f08185aa309a29de9e Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sun, 16 Jun 2024 19:32:54 +0900 Subject: [PATCH] fix: do not use assert-only never reached branch --- include/toml11/parser.hpp | 12 +++++++++--- include/toml11/types.hpp | 7 +++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/toml11/parser.hpp b/include/toml11/parser.hpp index 6abdf63..66948cd 100644 --- a/include/toml11/parser.hpp +++ b/include/toml11/parser.hpp @@ -157,9 +157,15 @@ parse_boolean(location& loc, const context& ctx) // it matches. gen value const auto str = reg.as_string(); const auto val = [&str]() { - if (str == "true") { return true; } - else if(str == "false") { return false; } - else {assert("never reach here" && false);} + if(str == "true") + { + return true; + } + else + { + assert(str == "false"); + return false; + } }(); // ---------------------------------------------------------------------- diff --git a/include/toml11/types.hpp b/include/toml11/types.hpp index 57a1fb7..75f55b2 100644 --- a/include/toml11/types.hpp +++ b/include/toml11/types.hpp @@ -147,9 +147,12 @@ read_int(const std::string& str, const source_location src, const std::uint8_t b { case 2: { return read_bin_int(str, src); } case 8: { return read_oct_int(str, src); } - case 10: { return read_dec_int(str, src); } case 16: { return read_hex_int(str, src); } - default: { assert(false); } + default: + { + assert(base == 10); + return read_dec_int(str, src); + } } }