Skip to content
Permalink
Browse files

Promote deletion of incomplete type warning to error

Deleting a pointer to incomplete type is undefined behavior in
all cases where the type has a non-trivial destructor. Since this is
the overwhelming majority of classes we have, it's worth making sure
this doesn't happen.
  • Loading branch information...
isilkor committed Apr 19, 2019
1 parent a43d4da commit 8b35da03f23850f56193b787b3f2debe618c78cb
Showing with 7 additions and 0 deletions.
  1. +7 −0 CMakeLists.txt
@@ -144,6 +144,13 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wredundant-decls -Wendif-labels -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Winit-self -Wsign-promo -Wno-reorder -Wno-unused-parameter -Wnon-virtual-dtor -Woverloaded-virtual -Wformat-security")
endif()

# Deleting a pointer to an incomplete type is undefined behavior in almost all cases, so we don't want that to happen
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4150")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=delete-incomplete")
endif()

if(WIN32 AND MINGW)
# Activate DEP and ASLR
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--nxcompat -Wl,--dynamicbase")

0 comments on commit 8b35da0

Please sign in to comment.
You can’t perform that action at this time.