From 8df5bd53da1c8ccb4628e85342b13ed65137b8d5 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Thu, 11 May 2023 11:16:08 +0200 Subject: [PATCH] AK: Silence false positive -Warray-bounds warning This regression has been reported to GCC's Bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109727 The formatting change looks like a clang-format 15 bug :( --- AK/ByteBuffer.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index 04f8afa3b0..e2fc73bbfe 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -117,10 +117,24 @@ public: [[nodiscard]] bool is_empty() const { return m_size == 0; } [[nodiscard]] size_t size() const { return m_size; } - [[nodiscard]] u8* data() { return m_inline ? m_inline_buffer : m_outline_buffer; } +#ifdef AK_COMPILER_GCC +# pragma GCC diagnostic push +// Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109727 +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + [[nodiscard]] u8* data() + { + return m_inline ? m_inline_buffer : m_outline_buffer; + } [[nodiscard]] u8 const* data() const { return m_inline ? m_inline_buffer : m_outline_buffer; } +#ifdef AK_COMPILER_GCC +# pragma GCC diagnostic pop +#endif - [[nodiscard]] Bytes bytes() { return { data(), size() }; } + [[nodiscard]] Bytes bytes() + { + return { data(), size() }; + } [[nodiscard]] ReadonlyBytes bytes() const { return { data(), size() }; } [[nodiscard]] AK::Bytes span() { return { data(), size() }; }