On Sat, 9 Nov 2024, Sad Clouds via Gcc wrote: > Even though there is nothing unsafe here and comparison to floating > point 0.0 value is well defined.
The point of the warning is that *if you are writing code that thinks of floating-point values as being approximations to real numbers* then such comparisons are suspect. If you are writing code that thinks of floating-point values as exactly represented members of their type (subject to any excess range and precision), rather than as approximations (at least as regards any floating-point numbers for which you use equality comparisons), and follows algorithms appropriate for fully defined floating-point operations, then you should not use that warning option for such code. I don't think this has anything to do with whether one operand of the comparison is a constant. It's still the case when comparing with 0.0 that it's OK if your algorithm is designed such that the other operand is exact, and questionable if it is an approximation. -- Joseph S. Myers josmy...@redhat.com