diff --git a/include/fmt/base.h b/include/fmt/base.h index a733a918..ec2326e0 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1678,12 +1678,13 @@ template struct arg_pack {}; template class format_string_checker { private: - type types_[max_of(1, NUM_ARGS)]; - named_arg_info named_args_[max_of(1, NUM_NAMED_ARGS)]; + type types_[static_cast(max_of(1, NUM_ARGS))]; + named_arg_info + named_args_[static_cast(max_of(1, NUM_NAMED_ARGS))]; compile_parse_context context_; using parse_func = auto (*)(parse_context&) -> const Char*; - parse_func parse_funcs_[max_of(1, NUM_ARGS)]; + parse_func parse_funcs_[static_cast(max_of(1, NUM_ARGS))]; public: template @@ -2338,8 +2339,9 @@ template struct named_arg_store { // args_[0].named_args points to named_args to avoid bloating format_args. - arg_t args[1 + NUM_ARGS]; - named_arg_info named_args[NUM_NAMED_ARGS]; + arg_t args[static_cast(1 + NUM_ARGS)]; + named_arg_info + named_args[static_cast(NUM_NAMED_ARGS)]; template FMT_CONSTEXPR FMT_ALWAYS_INLINE named_arg_store(T&... values) @@ -2370,10 +2372,10 @@ template struct format_arg_store { // +1 to workaround a bug in gcc 7.5 that causes duplicated-branches warning. - using type = - conditional_t[max_of(1, NUM_ARGS)], - named_arg_store>; + using type = conditional_t< + NUM_NAMED_ARGS == 0, + arg_t[static_cast(max_of(1, NUM_ARGS))], + named_arg_store>; type args; }; diff --git a/include/fmt/format.h b/include/fmt/format.h index 5aac87e4..6a0b5398 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1225,7 +1225,8 @@ FMT_CONSTEXPR auto do_format_base2e(int base_bits, Char* out, UInt value, out += size; do { const char* digits = upper ? "0123456789ABCDEF" : "0123456789abcdef"; - unsigned digit = static_cast(value & ((1 << base_bits) - 1)); + unsigned digit = static_cast( + value & ((static_cast(1) << base_bits) - 1)); *--out = static_cast(base_bits < 4 ? static_cast('0' + digit) : digits[digit]); } while ((value >>= base_bits) != 0); @@ -2017,7 +2018,7 @@ FMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, write_int_arg arg, const format_specs& specs) -> OutputIt { static_assert(std::is_same>::value, ""); - constexpr int buffer_size = num_bits(); + constexpr size_t buffer_size = num_bits(); char buffer[buffer_size]; if (is_constant_evaluated()) fill_n(buffer, buffer_size, '\0'); const char* begin = nullptr;