It just wanted to add that when extracting the arithmetic and
comparision code from above it works as expected:
$ cat test.cpp
#include <iostream>
int main() {
int a = 2147483647;
int b = 2147483647;
int sum = a + b;
std::cout << "sum = " << sum << '\n';
if (sum < 0)
std::cout << "sum < 0" << '\n';
else
std::cout << "sum >= 0" << '\n';
}
$ g++ test.cpp -o test
$ ./test
sum = -2
sum < 0
$ g++ --version|grep rel
g++ (GCC) 4.1.2 20060817 (prerelease) (Ubuntu 4.1.1-11ubuntu1)
--
[Egdy] gcc has a strange behaviour -2 > 0 ?
https://launchpad.net/bugs/57194
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs