From 72dc4491ea5759fa9b5c612b4c5bef4a05425c9e Mon Sep 17 00:00:00 2001 From: Kieran Clancy Date: Fri, 21 Jul 2023 00:00:45 +0930 Subject: [PATCH] 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. --- include/fmt/core.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 370b2f1e..7b442502 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2599,15 +2599,15 @@ template 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(num_args) : 1]; parse_context_type context_; parse_func parse_funcs_[num_args > 0 ? static_cast(num_args) : 1]; - type types_[num_args > 0 ? static_cast(num_args) : 1]; public: explicit FMT_CONSTEXPR format_string_checker(basic_string_view fmt) - : context_(fmt, num_args, types_), - parse_funcs_{&parse_format_specs...}, - types_{mapped_type_constant>::value...} {} + : types_{mapped_type_constant>::value...}, + context_(fmt, num_args, types_), + parse_funcs_{&parse_format_specs...} {} FMT_CONSTEXPR void on_text(const Char*, const Char*) {}