From f0340b8d22c8e2d9319726b8d90f9b3a3636882e Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sat, 5 Feb 2022 11:29:44 -0500 Subject: [PATCH] hle: ipc_helpers: Ignore -Wclass-memaccess This warning is triggered by GCC when copying into non-trivially default constructible types, as it uses the more restrictive std::is_trivial (which includes std::is_trivially_default_constructible) to determine whether memcpy is safe instead of std::is_trivially_copyable. --- src/core/hle/ipc_helpers.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index cf204f5704..026257115b 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -404,6 +404,11 @@ inline s32 RequestParser::Pop() { return static_cast(Pop()); } +// Ignore the -Wclass-memaccess warning on memcpy for non-trivially default constructible objects. +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif template void RequestParser::PopRaw(T& value) { static_assert(std::is_trivially_copyable_v, @@ -411,6 +416,9 @@ void RequestParser::PopRaw(T& value) { std::memcpy(&value, cmdbuf + index, sizeof(T)); index += (sizeof(T) + 3) / 4; // round up to word length } +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif template T RequestParser::PopRaw() {