Re: floating point warnings, and gcc 4 warnings in general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Scott Lipcon" <slipcon@xxxxxxxxx> writes:

>  I'm trying to figure out how to get gcc to warn on a specific problem
> that we found in our source code.   I've attached a simple test
> program that has a few places where floating point precision can
> potentially be lost or cause problems.   Specifically:
>     1)   Line 12,  returns a double as a float without an explicit
> cast - loss of precision.  Would like a warning here.
>     2)  Line 19,  same problem, but with fixed point - returns an int
> as a short, without a cast - loss of precision, would like a warning
>     3)  Line 31,  subtracts a float from a double (the constant is
> treated as a double, the variable is explicitly cast as a float.   In
> this particular case, as can be seen in the printf on line 34,  pi/2 -
> pi/2 does not equal zero.   This seems like it might be harder to
> check for, but I'd love to see a warning here as well.

Manuel López-Ibáñez is working on warnings along these lines as part
of a Google Summer of Code project.  See
    http://gcc.gnu.org/wiki/Wcoercion

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux