Marko Rauhamaa <[email protected]>:
> In this day and age, heavily optimized compilers (including gcc)
> actively exploit undefined behavior in code generation.
Example: Find the value of INT_MAX programmatically.
========================================================================
#include <stdio.h>
int main()
{
int n = 1;
while (n + 1 > n)
n++;
printf("%d\n", n);
return 0;
}
========================================================================
========================================================================
$ # Use gcc-4.9.2
$ cc -o test test.c
$ ./test
2147483647
$ cc -O9 -o test test.c
$ ./test
^C
========================================================================
The command "cc -S -O9 test.c" shows that the compiler compiles the
while loop into:
========================================================================
.L2:
jmp .L2
========================================================================
Marko
--
https://mail.python.org/mailman/listinfo/python-list