On Sat, 9 Nov 2024 11:49:56 -0800 Andrew Pinski <pins...@gmail.com> wrote:
> You can use the diagnostic pragma to disable it directly for the statement. Thanks for the tip. After a quick search, I came across this page, which explains it: https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html > But I will note comparing double even against 0 can be problematic. You > might not get exactly 0 in some cases with things like FMA or when using > x87 instructions set. I'm not sure I understand this. As far as I know, 0.0 can be represented exactly in a floating point type. So the statement "if (value == 0.0)" should always be true if value is exactly 0.0. I'm not really concerned about "value = 0.1 - 0.1" not resulting in 0.0. It is more of a case where value was explicitly initialised to 0.0 and then later used in the equality comparison. Thanks.