I am doing a x86 cross compile using gcc 8.3.0 with -ffast-math enabled of the following code:
#include <cmath>
double diff_double(double in)
{
auto tmp = 10 * std::log10(1. * 15e3);
return tmp - (10 * std::log10(1. * in));
}
int main()
{
return diff_double(15e3) == 0.;
}
On execution, I get a return value of 0 because the compiler optimized result for "tmp" differs from the runtime result.
Is this a valid behavior?
Godbold: https://godbolt.org/z/g2sev7
Thanks for your help