From 2e1df1dc78f38e04908abe1b26cd68953572e424 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 4 May 2008 11:20:55 +0300 Subject: [PATCH] Bug 1012: Compile with -fno-strict-overflow or -fwrapv. (cherry picked from commit b7312e6882ab9a1792ac8e082bdb7aae6971cae1) --- NEWS | 1 + configure.in | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/NEWS b/NEWS index 9b68f4f4..9165b2aa 100644 --- a/NEWS +++ b/NEWS @@ -323,6 +323,7 @@ To be released as 0.11.4. * bug 938: elinks -remote no longer needs a controlling tty * bug 939: fix FSP directory listing (some compiler options left it empty) * bug 978: Python's webbrowser.open_new_tab(URL) works since now +* bug 1012: compile with -fno-strict-overflow or -fwrapv if available * minor bug 54, Debian bug 338402: don't force the terminal to 8 bits with no parity, and don't disable XON/XOFF flow control either * minor bug 951 in user SMJS: garbage-collect SMJS objects on 'File -> diff --git a/configure.in b/configure.in index d32ca56a..7d32730f 100644 --- a/configure.in +++ b/configure.in @@ -1451,6 +1451,61 @@ if test "x$ac_cv_c_compiler_gnu" = "xyes"; then [AC_MSG_RESULT([no])]) EL_RESTORE_FLAGS done + + # Bug 1012: Some parts of ELinks do arithmetic with signed integers + # in such a way that an overflow is possible. GCC 4.2.1 warns + # "warning: assuming signed overflow does not occur when assuming + # that (X + c) > X is always true", which may be an incorrect + # optimization (although allowed by the standard), and breaks the + # build with -Werror. + # + # All of the following tests included -S -Wall -Wextra: + # + # GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3) + # * gcc-4.0 -O0: OK, compares the values + # * gcc-4.0 -O2: assumes no overflow, does not warn + # * gcc-4.0 -O0 -fno-strict-overflow: unrecognized command line option + # * gcc-4.0 -O0 -fwrapv: OK, compares the values + # * gcc-4.0 -O2 -fwrapv: OK, compares the values + # * gcc-4.0 -O0 -ftrapv: OK, calls __addvsi3 + # * gcc-4.0 -O2 -ftrapv: assumes no overflow, does not warn + # * gcc-4.0 -O0 -fwrapv -ftrapv: OK, calls __addvsi3 + # * gcc-4.0 -O2 -fwrapv -ftrapv: compares the values + # + # GCC: (GNU) 4.1.3 20070812 (prerelease) (Debian 4.1.2-15) + # * gcc-4.1 -O0: assumes no overflow, does not warn + # * gcc-4.1 -O2: assumes no overflow, does not warn + # * gcc-4.1 -O0 -fno-strict-overflow: unrecognized command line option + # * gcc-4.1 -O0 -fwrapv: OK, compares the values + # * gcc-4.1 -O2 -fwrapv: OK, compares the values + # * gcc-4.1 -O0 -ftrapv: OK, calls __addvsi3 + # * gcc-4.1 -O2 -ftrapv: compares the values + # * gcc-4.1 -O0 -fwrapv -ftrapv: OK, calls __addvsi3 + # * gcc-4.1 -O2 -fwrapv -ftrapv: compares the values + # + # GCC: (GNU) 4.2.1 (Debian 4.2.1-5) + # * gcc-4.2 -O0: OK, compares the values + # * gcc-4.2 -O2: assumes no overflow, warns about it + # * gcc-4.2 -O0 -fno-strict-overflow: OK, compares the values + # * gcc-4.2 -O2 -fno-strict-overflow: OK, compares the values + # * gcc-4.2 -O0 -fwrapv: OK, compares the values + # * gcc-4.2 -O2 -fwrapv: OK, compares the values + # * gcc-4.2 -O0 -ftrapv: OK, calls __addvsi3 + # * gcc-4.2 -O2 -ftrapv: compares the values + # * gcc-4.2 -O0 -fwrapv -ftrapv: OK, calls __addvsi3 + # * gcc-4.2 -O2 -fwrapv -ftrapv: compares the values + # + # Apparently, -ftrapv does not work reliably at all. + for overflow_flag in -fno-strict-overflow -fwrapv; do + AC_MSG_CHECKING([whether $CC accepts $overflow_flag]) + EL_SAVE_FLAGS + CFLAGS="$CFLAGS $overflow_flag" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [AC_MSG_RESULT([yes]) + break], + [AC_MSG_RESULT([no])]) + EL_RESTORE_FLAGS + done fi EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])