diff --git a/Source/Core/Common/Crypto/bn.cpp b/Source/Core/Common/Crypto/bn.cpp index 3dc8c75280..28bd216824 100644 --- a/Source/Core/Common/Crypto/bn.cpp +++ b/Source/Core/Common/Crypto/bn.cpp @@ -3,42 +3,45 @@ #include "Common/Crypto/bn.h" +#include #include #include #include "Common/CommonTypes.h" -static void bn_zero(u8* d, int n) +static void bn_zero(u8* d, const size_t n) { std::memset(d, 0, n); } -static void bn_copy(u8* d, const u8* a, int n) +static void bn_copy(u8* d, const u8* a, const size_t n) { std::memcpy(d, a, n); } -int bn_compare(const u8* a, const u8* b, int n) +int bn_compare(const u8* a, const u8* b, const size_t n) { return std::memcmp(a, b, n); } -void bn_sub_modulus(u8* a, const u8* N, int n) +void bn_sub_modulus(u8* a, const u8* N, const size_t n) { u8 c = 0; - for (int i = n - 1; i >= 0; --i) + for (size_t i = n; i > 0;) { + --i; u32 dig = N[i] + c; c = (a[i] < dig); a[i] -= dig; } } -void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n) +void bn_add(u8* d, const u8* a, const u8* b, const u8* N, const size_t n) { u8 c = 0; - for (int i = n - 1; i >= 0; --i) + for (size_t i = n; i > 0;) { + --i; u32 dig = a[i] + b[i] + c; c = (dig >= 0x100); d[i] = dig; @@ -51,11 +54,11 @@ void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n) bn_sub_modulus(d, N, n); } -void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n) +void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, const size_t n) { bn_zero(d, n); - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { for (u8 mask = 0x80; mask != 0; mask >>= 1) { @@ -66,13 +69,13 @@ void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n) } } -void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en) +void bn_exp(u8* d, const u8* a, const u8* N, const size_t n, const u8* e, const size_t en) { u8 t[512]; bn_zero(d, n); d[n - 1] = 1; - for (int i = 0; i < en; i++) + for (size_t i = 0; i < en; i++) { for (u8 mask = 0x80; mask != 0; mask >>= 1) { @@ -86,7 +89,7 @@ void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en) } // only for prime N -- stupid but lazy, see if I care -void bn_inv(u8* d, const u8* a, const u8* N, int n) +void bn_inv(u8* d, const u8* a, const u8* N, const size_t n) { u8 t[512], s[512]; diff --git a/Source/Core/Common/Crypto/bn.h b/Source/Core/Common/Crypto/bn.h index 4070fd5f00..2dcc8c864b 100644 --- a/Source/Core/Common/Crypto/bn.h +++ b/Source/Core/Common/Crypto/bn.h @@ -3,13 +3,15 @@ #pragma once +#include + #include "Common/CommonTypes.h" // bignum arithmetic -int bn_compare(const u8* a, const u8* b, int n); -void bn_sub_modulus(u8* a, const u8* N, int n); -void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n); -void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n); -void bn_inv(u8* d, const u8* a, const u8* N, int n); // only for prime N -void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en); +int bn_compare(const u8* a, const u8* b, size_t n); +void bn_sub_modulus(u8* a, const u8* N, size_t n); +void bn_add(u8* d, const u8* a, const u8* b, const u8* N, size_t n); +void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, size_t n); +void bn_inv(u8* d, const u8* a, const u8* N, size_t n); // only for prime N +void bn_exp(u8* d, const u8* a, const u8* N, size_t n, const u8* e, size_t en); diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index b97185e769..a9e7c35946 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -486,7 +486,7 @@ FSTEntry ScanDirectoryTree(std::string directory, bool recursive) } else if (cur_depth < prev_depth) { - while (dir_fsts.size() - 1 != cur_depth) + while (dir_fsts.size() != static_cast(cur_depth) + 1u) { calc_dir_size(dir_fsts.top()); dir_fsts.pop(); diff --git a/Source/Core/Common/HttpRequest.cpp b/Source/Core/Common/HttpRequest.cpp index a8ed0d26ed..b9c6756624 100644 --- a/Source/Core/Common/HttpRequest.cpp +++ b/Source/Core/Common/HttpRequest.cpp @@ -33,8 +33,8 @@ public: Response Fetch(const std::string& url, Method method, const Headers& headers, const u8* payload, size_t size, AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only); - static int CurlProgressCallback(Impl* impl, double dlnow, double dltotal, double ulnow, - double ultotal); + static int CurlProgressCallback(Impl* impl, curl_off_t dltotal, curl_off_t dlnow, + curl_off_t ultotal, curl_off_t ulnow); std::string EscapeComponent(const std::string& string); private: @@ -95,11 +95,12 @@ HttpRequest::Response HttpRequest::Post(const std::string& url, const std::strin reinterpret_cast(payload.data()), payload.size(), codes); } -int HttpRequest::Impl::CurlProgressCallback(Impl* impl, double dlnow, double dltotal, double ulnow, - double ultotal) +int HttpRequest::Impl::CurlProgressCallback(Impl* impl, curl_off_t dltotal, curl_off_t dlnow, + curl_off_t ultotal, curl_off_t ulnow) { // Abort if callback isn't true - return !impl->m_callback(dlnow, dltotal, ulnow, ultotal); + return !impl->m_callback(static_cast(dltotal), static_cast(dlnow), + static_cast(ultotal), static_cast(ulnow)); } HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback callback) @@ -116,7 +117,7 @@ HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback c if (m_callback) { curl_easy_setopt(m_curl.get(), CURLOPT_PROGRESSDATA, this); - curl_easy_setopt(m_curl.get(), CURLOPT_PROGRESSFUNCTION, CurlProgressCallback); + curl_easy_setopt(m_curl.get(), CURLOPT_XFERINFOFUNCTION, CurlProgressCallback); } // Set up error buffer diff --git a/Source/Core/Common/HttpRequest.h b/Source/Core/Common/HttpRequest.h index 921051c9c2..17b9fd3413 100644 --- a/Source/Core/Common/HttpRequest.h +++ b/Source/Core/Common/HttpRequest.h @@ -25,8 +25,7 @@ public: }; // Return false to abort the request - using ProgressCallback = - std::function; + using ProgressCallback = std::function; explicit HttpRequest(std::chrono::milliseconds timeout_ms = std::chrono::milliseconds{3000}, ProgressCallback callback = nullptr); diff --git a/Source/Core/Common/SettingsHandler.cpp b/Source/Core/Common/SettingsHandler.cpp index 109c80abb8..c36805d4ce 100644 --- a/Source/Core/Common/SettingsHandler.cpp +++ b/Source/Core/Common/SettingsHandler.cpp @@ -70,12 +70,10 @@ std::string SettingsHandler::GetValue(std::string_view key) const void SettingsHandler::Decrypt() { - const u8* str = m_buffer.data(); while (m_position < m_buffer.size()) { decoded.push_back((u8)(m_buffer[m_position] ^ m_key)); m_position++; - str++; m_key = (m_key >> 31) | (m_key << 1); } diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index baf7b87760..9187728c29 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "Common/Assert.h" #include "Common/CommonTypes.h" @@ -101,14 +102,9 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file, part_start = offset; // Copy cpmem now, because end_of_primitives isn't triggered until the first opcode after // primitive data, and the first opcode might update cpmem -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - std::memcpy(&cpmem, &analyzer.m_cpmem, sizeof(CPState)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + static_assert(std::is_trivially_copyable_v); + std::memcpy(static_cast(&cpmem), static_cast(&analyzer.m_cpmem), + sizeof(CPState)); } if (analyzer.m_end_of_primitives) { diff --git a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp index 15063c3f02..7cedf8299b 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp @@ -268,9 +268,7 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb) RecordInitialVideoMemory(); } - auto& system = Core::System::GetInstance(); - auto& command_processor = system.GetCommandProcessor(); - const auto& fifo = command_processor.GetFifo(); + const auto& fifo = Core::System::GetInstance().GetCommandProcessor().GetFifo(); EndFrame(fifo.CPBase.load(std::memory_order_relaxed), fifo.CPEnd.load(std::memory_order_relaxed)); }, diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.cpp index d656f81a4d..202145697e 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.cpp @@ -44,21 +44,21 @@ constexpr u32 VOICE_16_BIT_FLAG = 2; // These are used in the pre-2020 versions version constexpr u32 VOICE_PAUSE_OLD = 0x00000004; -constexpr u32 VOICE_LOOP_OLD = 0x00000008; // not used by the DSP -constexpr u32 VOICE_ONCE_OLD = 0x00000010; // not used by the DSP -constexpr u32 VOICE_STREAM_OLD = 0x00000020; // not used by the DSP +constexpr u32 VOICE_LOOP_OLD [[maybe_unused]] = 0x00000008; // not used by the DSP +constexpr u32 VOICE_ONCE_OLD [[maybe_unused]] = 0x00000010; // not used by the DSP +constexpr u32 VOICE_STREAM_OLD [[maybe_unused]] = 0x00000020; // not used by the DSP // These were changed in the 2020 version to account for the different flags constexpr u32 VOICE_PAUSE_NEW = 0x00000008; -constexpr u32 VOICE_LOOP_NEW = 0x00000010; // not used by the DSP -constexpr u32 VOICE_ONCE_NEW = 0x00000020; // not used by the DSP -constexpr u32 VOICE_STREAM_NEW = 0x00000040; // not used by the DSP +constexpr u32 VOICE_LOOP_NEW [[maybe_unused]] = 0x00000010; // not used by the DSP +constexpr u32 VOICE_ONCE_NEW [[maybe_unused]] = 0x00000020; // not used by the DSP +constexpr u32 VOICE_STREAM_NEW [[maybe_unused]] = 0x00000040; // not used by the DSP // These did not change between versions constexpr u32 VOICE_FINISHED = 0x00100000; -constexpr u32 VOICE_STOPPED = 0x00200000; // not used by the DSP +constexpr u32 VOICE_STOPPED [[maybe_unused]] = 0x00200000; // not used by the DSP constexpr u32 VOICE_RUNNING = 0x40000000; -constexpr u32 VOICE_USED = 0x80000000; // not used by the DSP +constexpr u32 VOICE_USED [[maybe_unused]] = 0x80000000; // not used by the DSP // 1<<4 = scale gain by 1/1, 2<<2 = PCM decoding from ARAM, 1<<0 = 8-bit reads constexpr u32 ACCELERATOR_FORMAT_8_BIT = 0x0019; diff --git a/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp b/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp index 4dfc0a30ee..6e5c3eac97 100644 --- a/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp +++ b/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp @@ -384,7 +384,8 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket& if (size > 0) { // only if contain data - if (static_cast(this_seq - ref->ack_num) >= 0 && data.size() >= size) + if (static_cast(this_seq - ref->ack_num) >= 0 && + data.size() >= static_cast(size)) { ref->tcp_socket.send(data.data(), size); ref->ack_num += size; diff --git a/Source/Core/Core/HW/MemoryInterface.cpp b/Source/Core/Core/HW/MemoryInterface.cpp index 7bba5450fe..4841b083b4 100644 --- a/Source/Core/Core/HW/MemoryInterface.cpp +++ b/Source/Core/Core/HW/MemoryInterface.cpp @@ -61,14 +61,7 @@ MemoryInterfaceManager::~MemoryInterfaceManager() = default; void MemoryInterfaceManager::Init() { static_assert(std::is_trivially_copyable_v); -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - std::memset(&m_mi_mem, 0, sizeof(MIMemStruct)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + std::memset(static_cast(&m_mi_mem), 0, sizeof(MIMemStruct)); } void MemoryInterfaceManager::Shutdown() diff --git a/Source/Core/Core/HW/ProcessorInterface.cpp b/Source/Core/Core/HW/ProcessorInterface.cpp index 70b34ccc81..cea84a4ab4 100644 --- a/Source/Core/Core/HW/ProcessorInterface.cpp +++ b/Source/Core/Core/HW/ProcessorInterface.cpp @@ -24,8 +24,8 @@ namespace ProcessorInterface { -constexpr u32 FLIPPER_REV_A = 0x046500B0; -constexpr u32 FLIPPER_REV_B = 0x146500B1; +constexpr u32 FLIPPER_REV_A [[maybe_unused]] = 0x046500B0; +constexpr u32 FLIPPER_REV_B [[maybe_unused]] = 0x146500B1; constexpr u32 FLIPPER_REV_C = 0x246500B1; ProcessorInterfaceManager::ProcessorInterfaceManager(Core::System& system) : m_system(system) diff --git a/Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp b/Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp index 3d65694167..3157e8b9c8 100644 --- a/Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.cpp @@ -136,14 +136,8 @@ static bool DeserializeExtensionState(DesiredWiimoteState* state, return false; auto& e = state->extension.data.emplace(); static_assert(std::is_trivially_copyable_v); -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - std::memcpy(&e, &serialized.data[offset], sizeof(T)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + std::memcpy(static_cast(&e), static_cast(&serialized.data[offset]), + sizeof(T)); return true; } diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 0aa235afd2..56c6f08aa5 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -254,7 +254,8 @@ bool NetPlayClient::Connect() // TODO: make this not hang ENetEvent netEvent; int net; - while ((net = enet_host_service(m_client, &netEvent, 5000)) > 0 && netEvent.type == 42) + while ((net = enet_host_service(m_client, &netEvent, 5000)) > 0 && + netEvent.type == ENetEventType(42)) // See PR #11381 and ENetUtil::InterceptCallback { // ignore packets from traversal server } diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index d05e043da1..41b406536b 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -891,7 +891,7 @@ void MemoryViewWidget::OnContextMenu(const QPoint& pos) auto* copy_hex = menu->addAction(tr("Copy Hex"), this, [this, addr] { OnCopyHex(addr); }); copy_hex->setEnabled(item_has_value); - auto* copy_value = menu->addAction(tr("Copy Value"), this, [this, item_selected] { + auto* copy_value = menu->addAction(tr("Copy Value"), this, [item_selected] { QApplication::clipboard()->setText(item_selected->text()); }); copy_value->setEnabled(item_has_value); diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp index 849a5b5550..317d12fefa 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -143,7 +143,7 @@ int main(int argc, char* argv[]) // code, which makes mouse inputs work again. // For more information: https://bugs.dolphin-emu.org/issues/12913 #if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)) - putenv("QT_XCB_NO_XI2=1"); + setenv("QT_XCB_NO_XI2", "1", true); #endif #endif diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 36371fd368..e9f8d2fff2 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -3,10 +3,8 @@ #include "InputCommon/ControllerInterface/Xlib/XInput2.h" -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wregister" #include -#pragma GCC diagnostic pop + #include #include #include diff --git a/Source/Core/UpdaterCommon/UpdaterCommon.cpp b/Source/Core/UpdaterCommon/UpdaterCommon.cpp index 408c313c95..9dd40c679f 100644 --- a/Source/Core/UpdaterCommon/UpdaterCommon.cpp +++ b/Source/Core/UpdaterCommon/UpdaterCommon.cpp @@ -58,7 +58,7 @@ void LogToFile(const char* fmt, ...) va_end(args); } -bool ProgressCallback(double total, double now, double, double) +bool ProgressCallback(s64 total, s64 now, s64, s64) { UI::SetCurrentProgress(static_cast(now), static_cast(total)); return true; diff --git a/Source/Core/VideoCommon/CPMemory.cpp b/Source/Core/VideoCommon/CPMemory.cpp index 3d72a6f70b..a42ee8fc2e 100644 --- a/Source/Core/VideoCommon/CPMemory.cpp +++ b/Source/Core/VideoCommon/CPMemory.cpp @@ -4,6 +4,7 @@ #include "VideoCommon/CPMemory.h" #include +#include #include "Common/ChunkFile.h" #include "Common/Logging/Log.h" @@ -17,14 +18,9 @@ CPState g_preprocess_cp_state; void CopyPreprocessCPStateFromMain() { -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - std::memcpy(&g_preprocess_cp_state, &g_main_cp_state, sizeof(CPState)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + static_assert(std::is_trivially_copyable_v); + std::memcpy(static_cast(&g_preprocess_cp_state), + static_cast(&g_main_cp_state), sizeof(CPState)); } std::pair GetCPRegInfo(u8 cmd, u32 value) diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 1c01356c99..150f38b307 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -608,14 +608,10 @@ AbstractPipelineConfig ShaderCache::GetGXPipelineConfig( static GXPipelineUid ApplyDriverBugs(const GXPipelineUid& in) { GXPipelineUid out; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - memcpy(&out, &in, sizeof(out)); // copy padding -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + // TODO: static_assert(std::is_trivially_copyable_v); + // GXPipelineUid is not trivially copyable because RasterizationState and BlendingState aren't + // either, but we can pretend it is for now. This will be improved after PR #10848 is finished. + memcpy(static_cast(&out), static_cast(&in), sizeof(out)); // copy padding pixel_shader_uid_data* ps = out.ps_uid.GetUidData(); BlendingState& blend = out.blending_state; @@ -785,14 +781,10 @@ ShaderCache::GetGXPipelineConfig(const GXPipelineUid& config_in) static GXUberPipelineUid ApplyDriverBugs(const GXUberPipelineUid& in) { GXUberPipelineUid out; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - memcpy(&out, &in, sizeof(out)); // Copy padding -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + // TODO: static_assert(std::is_trivially_copyable_v); + // GXUberPipelineUid is not trivially copyable because RasterizationState and BlendingState aren't + // either, but we can pretend it is for now. This will be improved after PR #10848 is finished. + memcpy(static_cast(&out), static_cast(&in), sizeof(out)); // Copy padding if (g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader) out.vertex_format = nullptr; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 15f79f99bd..bcffe8e4ca 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -657,8 +657,8 @@ void TextureCacheBase::DoSaveState(PointerWrap& p) } auto doList = [&p](auto list) { - u32 size = static_cast(list.size()); - p.Do(size); + u32 list_size = static_cast(list.size()); + p.Do(list_size); for (const auto& it : list) { p.Do(it.first); diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index 0236201001..fb24803f1c 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -153,14 +154,8 @@ NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl) // The padding in the structs can cause the memcmp() in the map to create duplicates. // Avoid this by initializing the padding to zero. PortableVertexDeclaration new_decl; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - std::memset(&new_decl, 0, sizeof(new_decl)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + static_assert(std::is_trivially_copyable_v); + std::memset(static_cast(&new_decl), 0, sizeof(new_decl)); new_decl.stride = decl.stride; auto MakeDummyAttribute = [](AttributeFormat& attr, ComponentFormat type, int components,