[New-bugs-announce] [issue12985] Check signed arithmetic overflow in ./configure

Stefan Krah report at bugs.python.org
Thu Sep 15 11:34:37 CEST 2011


New submission from Stefan Krah <stefan-usenet at bytereef.org>:

I'm not sure if this is a good idea: I wonder if it would be an option
to check for overflow behavior at the bottom of ./configure and print a
warning. The patch appears to work for gcc, clang and suncc. It would
have caught the problem in #12973.


The Intel compiler is the odd one here. Even with -O0 this particular
overflow is undefined, but I can't remember seeing the specific
test failures from #12973. So the drawback is that the patch might
give false positives.



$ cat overflow_is_defined.c
#include <limits.h>
int overflow_is_defined(int x) {
    if (x + 1000 < x)
        return 0;
    return 1;
}
int main() {
    return overflow_is_defined(INT_MAX);
}



gcc-4.4.3
=========

$ gcc -Wall -W -O0 -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
$ gcc -Wall -W -O2 -o overflow_is_defined overflow_is_defined.c
overflow_is_defined.c: In function ‘overflow_is_defined’:
overflow_is_defined.c:3: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false
$ ./overflow_is_defined || echo "undefined"
undefined
$ gcc -Wall -W -O2 -fwrapv -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
$

clang-3.0
=========

$ clang -Wall -W -O0 -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
$ clang -Wall -W -O2 -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
undefined
$ clang -Wall -W -fwrapv -O2 -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
$

suncc-12.2
==========

$ suncc -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
$ suncc -O2 -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
$

icc-12.0.0
==========

$ icc -Wall -O0 -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
undefined
$ icc -Wall -O2 -o overflow_is_defined overflow_is_defined.c
$ ./overflow_is_defined || echo "undefined"
undefined
$

----------
files: configure_catch_overflow.diff
keywords: patch
messages: 144071
nosy: skrah
priority: normal
severity: normal
stage: patch review
status: open
title: Check signed arithmetic overflow in ./configure
type: feature request
Added file: http://bugs.python.org/file23160/configure_catch_overflow.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12985>
_______________________________________


More information about the New-bugs-announce mailing list