Il 01/07/2014 07:42, Alexey Kardashevskiy ha scritto:
This is wrong actually. The problem here that compiler knows how to
optimize constants. sin(0.0) is the one while log(0.0) is not (it is
supposed to throw error or something as it the result is infinity).
So the correct test here could be:
int main(void) { volatile double x = 1; return isnan(sin(x)); }
But I am afraid pretty soon compilers will learn how to optimize this as
well :)
I think something like "double x; int f(void) {return isnan(sin(x));}"
should be bullet proof.
Paolo