From cf9caa069a13774080a67c00a9ebdd1b51bec687 Mon Sep 17 00:00:00 2001 From: iphydf Date: Fri, 8 Jun 2018 23:48:40 +0000 Subject: [PATCH] In DEBUG mode, make toxcore crash on signed integer overflow. Signed overflow is undefined behaviour, so in debug mode, we want to make it fail in a noisy way. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd22e8d9..411d75d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,8 @@ if(NOT MSVC) # Allows wine to display source code file names and line numbers on crash in its backtrace add_flag("-gdwarf-2") endif() + # Crash on signed integer overflow. + add_flag("-ftrapv") endif() option(WARNINGS "Enable additional compiler warnings" ON)