From 9ae78c50fd6dd6faa4b4bc9afa91830f8170399b Mon Sep 17 00:00:00 2001 From: Lenny Maiorani Date: Wed, 7 Oct 2020 11:21:00 -0400 Subject: [PATCH] VariadicFormatParams: Use initialized data to create parent class Problem: - m_data is being passed to the constructor of the parent class before it is initialized. This is not really a problem because the compiler knows the location and it is only a span being constructed, but it triggers a warning in clang for use-before-init. Solution: - Initialize using a default constructed array and then overwrite it inside the constructor after the member is initialized. --- AK/Format.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/AK/Format.h b/AK/Format.h index 9d7ab3bc42..b11139ae36 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -164,13 +164,9 @@ private: class TypeErasedFormatParams { public: - explicit TypeErasedFormatParams(Span parameters) - : m_parameters(parameters) - { - } - Span parameters() const { return m_parameters; } + void set_parameters(Span parameters) { m_parameters = parameters; } size_t take_next_index() { return m_next_index++; } size_t decode(size_t value, size_t default_value = 0); @@ -195,9 +191,9 @@ public: static_assert(sizeof...(Parameters) <= max_format_arguments); explicit VariadicFormatParams(const Parameters&... parameters) - : TypeErasedFormatParams(m_data) - , m_data({ TypeErasedParameter { ¶meters, TypeErasedParameter::get_type(), __format_value }... }) + : m_data({ TypeErasedParameter { ¶meters, TypeErasedParameter::get_type(), __format_value }... }) { + this->set_parameters(m_data); } private: