From 7d733c5ccdd3a41e04a546382ab06ff734264f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 10 May 2016 10:21:56 +0200 Subject: [PATCH] cmake: add -fcheck-new to cxx_compile_flags GCC assumes that operator new never returns null, but throws an exception instead. This is defined by the C++ standard, and thus ok. But we disable exceptions with -fno-exceptions, so we break this assumption. GCC then goes ahead and removes some of our nullptr checks. This flag removes the assumption. This adds ~1.4kB to the binary size of the px4fmu-v4 target. --- cmake/common/px4_base.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index 1c461ec282..8f7ebcf048 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -643,6 +643,7 @@ function(px4_add_common_flags) set(cxx_compile_flags -g -fno-exceptions + -fcheck-new -fno-rtti -std=gnu++0x -fno-threadsafe-statics