From 6bcc3fd21694b5634cc006915bd049cf460a9a8d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 19 Jul 2019 10:14:32 +0200 Subject: [PATCH] Fix warnings --- include/fmt/safe-duration-cast.h | 2 +- test/scan.h | 2 +- test/std-format-test.cc | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/fmt/safe-duration-cast.h b/include/fmt/safe-duration-cast.h index 25302f79..61226e27 100644 --- a/include/fmt/safe-duration-cast.h +++ b/include/fmt/safe-duration-cast.h @@ -271,7 +271,7 @@ To safe_duration_cast(std::chrono::duration from, ec = 1; return {}; } - count *= Factor::num; + count *= static_cast(Factor::num); } // this can't go wrong, right? den>0 is checked earlier. diff --git a/test/scan.h b/test/scan.h index 9f0b35f4..c0789a30 100644 --- a/test/scan.h +++ b/test/scan.h @@ -167,7 +167,7 @@ struct scan_handler : error_handler { } void on_arg_id() { on_arg_id(next_arg_id_++); } - void on_arg_id(unsigned id) { + void on_arg_id(int id) { if (id >= args_.size) on_error("argument index out of range"); arg_ = args_.data[id]; } diff --git a/test/std-format-test.cc b/test/std-format-test.cc index 152176a0..e23d8df4 100644 --- a/test/std-format-test.cc +++ b/test/std-format-test.cc @@ -107,7 +107,8 @@ template <> struct std::formatter { // Parses a width argument id in the format { }. constexpr auto parse(format_parse_context& ctx) { auto iter = ctx.begin(); - auto get_char = [&]() { return iter != ctx.end() ? *iter : 0; }; + // auto get_char = [&]() { return iter != ctx.end() ? *iter : 0; }; + auto get_char = [&]() { return iter != ctx.end() ? *iter : '\0'; }; if (get_char() != '{') return iter; ++iter; char c = get_char(); @@ -124,7 +125,9 @@ template <> struct std::formatter { [](auto value) -> int { if constexpr (!is_integral_v) throw format_error("width is not integral"); - else if (value < 0 || value > numeric_limits::max()) + // else if (value < 0 || value > numeric_limits::max()) + else if (fmt::internal::is_negative(value) < 0 || + value > numeric_limits::max()) throw format_error("invalid width"); else return value;