On 2011-12-21 08:51:39 +0100, David Brown wrote: > But I expect that you know the details a lot better than me. If the > compiler can guarantee consistent and expected results in cases like yours > involving simple assignments, then it would make sense to change the > "-Wfloat-equal" not to trigger in such situations. After all, the point of > the warning is to help users avoid code that might not do what it seems to > do - if it /does/ do the expected thing, then there is no need of a warning. Floating point is tricky. You can't ask the compiler to detect every potential problems. That's not possible. Otherwise you would have too many false positives (-Wfloat-equal being one of the causes). For instance, according to Usenet posts in C and Perl groups, users often regard something like double x = 0.1; as exact. So, would you want the compiler to issue a warning every time a constant that cannot be represented exactly is used? I'd say no, even though the consequences can be disastrous[*]. Users should learn how FP works instead of relying on the compiler to detect their mistakes. [*] This example isn't much different from http://www.ima.umn.edu/~arnold/disasters/patriot.html (where all calculations could have been done exactly, if the code were better designed), which lead to 28 people killed. -- 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)