Reenable 4611 and 4703 (#66792)
authorAaron Robinson <arobins@microsoft.com>
Fri, 18 Mar 2022 01:59:24 +0000 (21:59 -0400)
committerGitHub <noreply@github.com>
Fri, 18 Mar 2022 01:59:24 +0000 (18:59 -0700)
eng/native/configurecompiler.cmake
src/coreclr/vm/fcall.h

index 469eb5f..60d2b2b 100644 (file)
@@ -604,9 +604,7 @@ if (MSVC)
   add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4459>) # declaration of 'identifier' hides global declaration
   add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4463>) # overflow; assigning value to bit-field that can only hold values from low_value to high_value
   add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4505>) # unreferenced function with internal linkage has been removed
-  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4611>) # interaction between 'function' and C++ object destruction is non-portable
   add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4702>) # unreachable code
-  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4703>) # potentially uninitialized local pointer variable 'var' used
   add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4706>) # assignment within conditional expression
   add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4733>) # Inline asm assigning to 'FS:0' : handler not registered as safe handler
   add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4815>) # 'var': zero-sized array in stack object will have no elements (unless the object is an aggregate that has been aggregate initialized)
index 8bed3fb..0c65542 100644 (file)
@@ -308,6 +308,21 @@ private:
 #endif // _DEBUG
 };
 
+// These macros are used to narrowly suppress
+// warning 4611 - interaction between 'function' and C++ object destruction is non-portable
+// See usage of setjmp() and inclusion of setjmp.h for reasoning behind usage.
+#ifdef _MSC_VER
+#define DISABLE_4611()          \
+    _Pragma("warning(push)")    \
+    _Pragma("warning(disable:4611)")
+
+#define RESET_4611()    \
+    _Pragma("warning(pop)")
+#else
+#define DISABLE_4611()
+#define RESET_4611()
+#endif // _MSC_VER
+
 #define PERMIT_HELPER_METHOD_FRAME_BEGIN()                                  \
         if (1)                                                              \
         {                                                                   \
@@ -318,7 +333,9 @@ private:
         else                                \
         {                                   \
             jmp_buf ___jmpbuf;              \
+            DISABLE_4611()                  \
             setjmp(___jmpbuf);              \
+            RESET_4611()                    \
             __assume(0);                    \
         }