GCC Handling Float comparison differently at different Optimization Levels GCC Handling Float comparison differently at different Optimization Levels linux linux

GCC Handling Float comparison differently at different Optimization Levels


The optimization level and surrounding code may affect whether the values used in the diff_val calculation are being fetched from memory, or from registers. The processormay be using 80-bit internal floating point registers in one case, and 32-bit floatingpoint values from memory in the other case, giving unexpected results.

Yet another reason to avoid using == for floating point comparisons!