------- Additional Comments From mathieu at malaterre dot com  2005-07-06 02:32 
-------
Using gcc --version:
g++ (GCC) 4.1.0 20050607 (experimental)

I still cannot get anything using the -ftrapv:

Ex is:

#include <iostream>

int main()
{
  const unsigned int a = 11;
  const unsigned int b = 10;
  const double t = 0.5;
  const unsigned int c = a + t * (b -a);
  std::cout << "c=" << c << std::endl;
  const unsigned int d = (1.0 - t) * a + t * b;
  std::cout << "d=" << d << std::endl;

  return 0;
}


compile line:

$ /usr/lib/gcc-snapshot/bin/g++ -O3 -ftrapv test.c

$ ./a.out
c=2147483658
d=10

It looks like -ftrapv only works on signed overflow.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17645

Reply via email to