clang and gcc assume that signed integers never overflow.
This leads to unexpected bugs when optimizer removes bound checks etc.
Bug:
27703278
Bug:
22715185
Change-Id: Iab4c884fa190d05c0ac9236d01eeeb190e765e69
$(deqp_compile_flags)
LOCAL_SDK_VERSION := 9
-LOCAL_CPPFLAGS += -Wno-non-virtual-dtor
+LOCAL_CPPFLAGS += -Wno-non-virtual-dtor -fwrapv
LOCAL_NDK_STL_VARIANT := gnustl_static
LOCAL_RTTI_FLAG := -frtti -fexceptions
LOCAL_MULTILIB := both
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS} ${WARNING_FLAGS} -ansi -pedantic ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_FLAGS} ${WARNING_FLAGS}")
+ # Force compiler to generate code where integers have well defined overflow
+ # Turn on -Wstrict-overflow=5 and check all warnings before removing
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fwrapv")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fwrapv")
elseif (DE_COMPILER_IS_MSC)
# Compiler flags for msc