mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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.
This commit is contained in:
parent
fcee80dd69
commit
9ae78c50fd
Notes:
sideshowbarker
2024-07-19 01:59:35 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/9ae78c50fd6 Pull-request: https://github.com/SerenityOS/serenity/pull/3708
1 changed files with 3 additions and 7 deletions
10
AK/Format.h
10
AK/Format.h
|
@ -164,13 +164,9 @@ private:
|
|||
|
||||
class TypeErasedFormatParams {
|
||||
public:
|
||||
explicit TypeErasedFormatParams(Span<const TypeErasedParameter> parameters)
|
||||
: m_parameters(parameters)
|
||||
{
|
||||
}
|
||||
|
||||
Span<const TypeErasedParameter> parameters() const { return m_parameters; }
|
||||
|
||||
void set_parameters(Span<const TypeErasedParameter> 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<Parameters>(), __format_value<Parameters> }... })
|
||||
: m_data({ TypeErasedParameter { ¶meters, TypeErasedParameter::get_type<Parameters>(), __format_value<Parameters> }... })
|
||||
{
|
||||
this->set_parameters(m_data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue