diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index a10297b7d6c666..183811018533aa 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -598,14 +598,13 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options($<$:-Wno-stringop-overflow>) add_compile_options($<$:-Wno-restrict>) add_compile_options($<$:-Wno-stringop-truncation>) + add_compile_options($<$:-Wno-class-memaccess>) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0) # this warning is only reported by g++ 11 in debug mode when building # src/coreclr/vm/stackingallocator.h. It is a false-positive, fixed in g++ 12. # see: https://github.com/dotnet/runtime/pull/69188#issuecomment-1136764770 add_compile_options($<$:-Wno-placement-new>) - - add_compile_options($<$:-Wno-class-memaccess>) endif() if (CMAKE_CXX_COMPILER_ID) diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 073d758c81b87c..7581c0c68311a9 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -6539,7 +6539,7 @@ HRESULT Debugger::LaunchDebuggerForUser(Thread * pThread, EXCEPTION_POINTERS * p // once and leave them set without the risk of clobbering something we care about. JIT_DEBUG_INFO Debugger::s_DebuggerLaunchJitInfo = {0}; EXCEPTION_RECORD Debugger::s_DebuggerLaunchJitInfoExceptionRecord = {0}; -CONTEXT Debugger::s_DebuggerLaunchJitInfoContext = {0}; +CONTEXT Debugger::s_DebuggerLaunchJitInfoContext = {}; //---------------------------------------------------------------------------- // diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 7bc67f1f805a36..92455bc8a491b0 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -1531,6 +1531,14 @@ typedef struct _XMM_SAVE_AREA32 { typedef struct DECLSPEC_ALIGN(16) _CONTEXT { + _CONTEXT() = default; + _CONTEXT(const _CONTEXT& ctx) + { + *this = ctx; + } + + _CONTEXT& operator=(const _CONTEXT& ctx); + // // Register parameter home addresses. // diff --git a/src/coreclr/pal/src/thread/context.cpp b/src/coreclr/pal/src/thread/context.cpp index 07afeea40d486c..a9ed8c269a89c7 100644 --- a/src/coreclr/pal/src/thread/context.cpp +++ b/src/coreclr/pal/src/thread/context.cpp @@ -1880,3 +1880,29 @@ DBG_FlushInstructionCache( #endif return TRUE; } + +#ifdef HOST_AMD64 +CONTEXT& CONTEXT::operator=(const CONTEXT& ctx) +{ + size_t copySize; + if (ctx.ContextFlags & CONTEXT_XSTATE & CONTEXT_AREA_MASK) + { + if ((ctx.XStateFeaturesMask & XSTATE_MASK_AVX512) == XSTATE_MASK_AVX512) + { + copySize = sizeof(CONTEXT); + } + else + { + copySize = offsetof(CONTEXT, KMask0); + } + } + else + { + copySize = offsetof(CONTEXT, XStateFeaturesMask); + } + + memcpy(this, &ctx, copySize); + + return *this; +} +#endif // HOST_AMD64 diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index 2e93bebc8ccf6c..cec1175c9c022e 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -1286,7 +1286,7 @@ bool FixNonvolatileRegisters(UINT_PTR uOriginalSP, } CONTRACTL_END; - CONTEXT _ctx = {0}; + CONTEXT _ctx = {}; // Ctor will initialize it to NULL REGDISPLAY regdisp;