mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
cmake: do not optimize away nullptr checks
OBJECTTYPE::exists() and SOLDIERTYPE::exists()/DeleteSoldier() are called on null pointers by design and guard with `this == NULL`. That is undefined behaviour, so clang infers `this` is non-null: it deletes the guard inside the callee *and* deletes null checks that follow a call in the caller, which is an access violation at /O2 in code MSVC has always compiled the naive way. The caller-side inference happens in every translation unit that calls one of these, so this has to be global rather than per-file; there is no per-function attribute or pragma for it. Drop it once nothing relies on a null `this`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
committed by
majcosta
co-authored by
Claude Fable 5
parent
c3e2d1ae3d
commit
dcb4b5bfea
@@ -42,6 +42,10 @@ if(ADDRESS_SANITIZER)
|
|||||||
add_compile_options($<IF:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>,-fsanitize=address,>)
|
add_compile_options($<IF:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>,-fsanitize=address,>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
add_compile_options(-fno-delete-null-pointer-checks)
|
||||||
|
endif()
|
||||||
|
|
||||||
# whether we are using MSBuild as a generator
|
# whether we are using MSBuild as a generator
|
||||||
set(usingMsBuild $<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>)
|
set(usingMsBuild $<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user