diff --git a/configure.in b/configure.in --- a/configure.in +++ b/configure.in @@ -4246,6 +4246,36 @@ AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;; esac +# Check whether signed arithmetic overflow is well defined: +SIGNED_OVERFLOW_WARN=" +***************************** WARNING ********************************* + +Signed arithmetic overflow is undefined. It is not safe to run Python. +Check if your compiler supports a flag similar to gcc's -fwrapv and +recompile. + +***************************** WARNING ********************************* +" + +AC_MSG_CHECKING(whether signed arithmetic overflow is well defined) +saved_cflags="$CFLAGS" +CFLAGS="$BASECFLAGS $OPT $CFLAGS $EXTRA_CFLAGS" +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +int overflow_is_defined(int x) { + if (x + 1000 < x) + return 0; + return 1; +} +int main() { + return overflow_is_defined(INT_MAX); +} +]])], +[have_well_defined_overflow=yes], +[have_well_defined_overflow=no], +[have_well_defined_overflow=cross_compiling]) +CFLAGS="$saved_cflags" +AC_MSG_RESULT($have_well_defined_overflow) AC_SUBST(THREADHEADERS) @@ -4286,3 +4316,7 @@ -s Modules Modules/Setup.config \ Modules/Setup.local Modules/Setup mv config.c Modules + +if test "$have_well_defined_overflow" = no; then + echo "$SIGNED_OVERFLOW_WARN" +fi