Skip to content

Commit

Permalink
Fix format_string_checker initialisation order (#3542)
Browse files Browse the repository at this point in the history
Linter (clang-tidy) complains about uninitialised fields in
format_string_checker since types_ is passed to context_ before being
initialised. Fixes #3541.
  • Loading branch information
kieranclancy authored Jul 20, 2023
1 parent 9bea6ec commit 72dc449
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2599,15 +2599,15 @@ template <typename Char, typename... Args> class format_string_checker {
// needed for compile-time checks: https://godbolt.org/z/GvWzcTjh1.
using parse_func = const Char* (*)(parse_context_type&);

type types_[num_args > 0 ? static_cast<size_t>(num_args) : 1];
parse_context_type context_;
parse_func parse_funcs_[num_args > 0 ? static_cast<size_t>(num_args) : 1];
type types_[num_args > 0 ? static_cast<size_t>(num_args) : 1];

public:
explicit FMT_CONSTEXPR format_string_checker(basic_string_view<Char> fmt)
: context_(fmt, num_args, types_),
parse_funcs_{&parse_format_specs<Args, parse_context_type>...},
types_{mapped_type_constant<Args, buffer_context<Char>>::value...} {}
: types_{mapped_type_constant<Args, buffer_context<Char>>::value...},
context_(fmt, num_args, types_),
parse_funcs_{&parse_format_specs<Args, parse_context_type>...} {}

FMT_CONSTEXPR void on_text(const Char*, const Char*) {}

Expand Down

0 comments on commit 72dc449

Please sign in to comment.