authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2025-06-17 19:42:13-06:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-18 16:41:25+02:00
logf3940ad858937cc4bb2e1b99828183e070f40bf9
tree57027c0969a7e78899873f29b19246ff514f8223
parent850655f06b7dd8dc6e637d4980e6b7f9ac1b43d9

windows: MSVC: disable extra dubious Microsoft runtime checks

Cmake by default adds the `/RTC1` compiler flag for debug builds. However, this causes C code that conforms to the C standard and has well-defined behavior to trap. Here I've updated CMAKE to use the more lenient `/RTCs` by default which removes the uninitialized variable checks but keeps the stack error checks.

1 files changed, 6 insertions(+), 0 deletions(-)

CMakeLists.txt+6
...@@ -694,6 +694,12 @@ if(MSVC)...@@ -694,6 +694,12 @@ if(MSVC)
694 set(ZIG_DIA_GUIDS_LIB "${MSVC_DIA_SDK_DIR}/lib/amd64/diaguids.lib")694 set(ZIG_DIA_GUIDS_LIB "${MSVC_DIA_SDK_DIR}/lib/amd64/diaguids.lib")
695 string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_DIA_GUIDS_LIB_ESCAPED "${ZIG_DIA_GUIDS_LIB}")695 string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_DIA_GUIDS_LIB_ESCAPED "${ZIG_DIA_GUIDS_LIB}")
696 endif()696 endif()
697
698 # The /RTC[c][s][u] flag enables extra runtime checks. ("/RTC1" == "/RTCsu")
699 # The "c" (PossibleDataLoss) and "u" (UninitializeVariable) flags trap on valid C code so we disable
700 # them. The "s" flag seems like it might be OK.
701 string(REPLACE "/RTC1" "/RTCs" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
702 string(REPLACE "/RTC1" "/RTCs" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
697endif()703endif()
698704
699configure_file (705configure_file (