Fix format_string_checker initialisation order (#3542)

Linter (clang-tidy) complains about uninitialised fields in
format_string_checker since types_ is passed to context_ before being
initialised. Fixes #3541.
This commit is contained in:
Kieran Clancy 2023-07-21 00:00:45 +09:30 committed by GitHub
parent 9bea6ec04a
commit 72dc4491ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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*) {}