On 2011-11-04 01:28:00 +1100, leon zadorin wrote: > On 11/3/11, Vincent Lefevre <vincent+gcc@xxxxxxxxxx> wrote: > > I'd say that this wouldn't be much useful, because similar problems > > can also occur at run time, and if you use options like -ffast-math, > > you won't be able to tell whether your program works correctly... > > unless you can prove that no overflows (etc.) can occur. But if you > > can do that, you no longer need GCC to do this for you for the > > particular case of compile-time calculations. > > But as I had mentioned in my original post -- there is a way to detect > this at runtime, even if compiler optimizes based on presumptions of > finite math etc implied by -ffast-math. Hmm... Yes, this should be possible. But I'm not sure this is easy. The reason is that the rounding mode used at compile time may be different than the rounding mode used at run time, so that there may be an overflow when an expression is evaluated at compile time (in which case the compile-time evaluation is discarded, AFAIK[*]) while there will be no overflows at run time. In such a case, a warning could be regarded as a bug. [*] From Kaveh R. GHAZI in the gcc mailing-list on 2008-01-03: "So I tried that, but mpfr_gamma on that value sets the global underflow flag. If overflow/underflow are set by mpfr, GCC will intentionally bypass folding. So this particular case is not something I can use." -- Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)