Inconsistent spilling of floating point causes simple floating point comparison to fail in 32 bit #42470
Labels
bugzilla
Issues migrated from bugzilla
clang:codegen
IR generation bugs: mangling, exceptions, etc.
invalid
Resolved as invalid, i.e. not a bug
Extended Description
In the following code, the assertion fails when compiled for and run in 32 bit mode:
Here, notice that both the right hand side and the left hand side of the comparison are "the same", the only difference being that in the left hand side, we cached the value of
max() - min()
into a local variable (x). When storing both the left hand side and the right hand side into named variables, the comparison succeeds:This only reproduces in 32 bit mode. Howard Hinnant hypothesized this was caused by the compiler storing one in a register and the other one on the stack, when the register might not be able to hold a true IEEE 64 bit double.
I know comparing floating point values is normally frowned upon, so feel free to close this as "You shouldn't be doing this". However, since the calculation is incredibly simple and the difference between the right and the left hand sides is just "stashing to a variable", I thought this might still be considered a bug.
The text was updated successfully, but these errors were encountered: