-Wfloat-equal and comparison to zero
Sad Clouds
cryintothebluesky@gmail.com
Sat Nov 9 19:17:52 GMT 2024
Hello, I don't know if this is a known GCC bug or intentional design,
but code like this:
double value = 0.0;
...
if (value == 0.0)
{
...
}
Results in the following warning with gcc-12.2.0:
"... warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe"
Even though there is nothing unsafe here and comparison to floating
point 0.0 value is well defined.
The LLVM clang seems to handle this correctly and does not produce any
warnings with -Wfloat-equal option.
Is there any way to silence GCC without disabling -Wfloat-equal?
Thanks.
More information about the Gcc
mailing list