Bug 1377550 Add -d2UndefIntOverflow- flag to disable dangerous optimizations
MozReview-Commit-ID: BHGGMD9qnqR
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -179,16 +179,19 @@ case "$target" in
AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
case "$CC_VERSION" in
19*)
_CC_SUITE=14
MSVC_C_RUNTIME_DLL=vcruntime140.dll
MSVC_CXX_RUNTIME_DLL=msvcp140.dll
+ # Disable optimizations that remove code that 'can't be reached' (because of undefined behavior)
+ CXXFLAGS="$CXXFLAGS -d2UndefIntOverflow-"
+
# C5026: move constructor was implicitly defined as deleted
CXXFLAGS="$CXXFLAGS -wd5026"
# C5027: move assignment operator was implicitly defined as deleted
CXXFLAGS="$CXXFLAGS -wd5027"
# -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
--- a/old-configure.in
+++ b/old-configure.in
@@ -241,16 +241,19 @@ case "$target" in
MSVC_C_RUNTIME_DLL=vcruntime140.dll
MSVC_CXX_RUNTIME_DLL=msvcp140.dll
MOZ_CHECK_HEADER(dia2.h, MSVC_HAS_DIA_SDK=1)
if test -n "$MSVC_HAS_DIA_SDK"; then
AC_DEFINE(MSVC_HAS_DIA_SDK)
fi
+ # Disable optimizations that remove code that 'can't be reached' (because of undefined behavior)
+ CXXFLAGS="$CXXFLAGS -d2UndefIntOverflow-"
+
# C5026: move constructor was implicitly defined as deleted
CXXFLAGS="$CXXFLAGS -wd5026"
# C5027: move assignment operator was implicitly defined as deleted
CXXFLAGS="$CXXFLAGS -wd5027"
# -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"