------- Additional Comments From mathieu at malaterre dot com 2005-07-06 03:00 ------- Using gcc --version: g++ (GCC) 4.1.0 20050607 (experimental)
I can still reproduce the same unsafe operation: #include <iostream> int main() { unsigned int l = (unsigned int)-1; const int a = l/2; const int b = l/2+1; const double t = 0.5; const int c = a + t * (b -a); std::cout << "c=" << c << std::endl; const int d = (1.0 - t) * a + t * b; std::cout << "d=" << d << std::endl; return 0; } $ /usr/lib/gcc-snapshot/bin/g++ -O3 -ftrapv test.c $ ./a.out c=2147483647 d=0 I cannot seems to find a way to generate traps on overflow. -- What |Removed |Added ---------------------------------------------------------------------------- Component|c++ |c http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17645