Suppose i have:
double f(const double *r) {
return 0*(r[0]*r[1]);
}
should compiler be able to optimize out the segment, or does it sti
Depends on whether the compiler implements IEEE754. Neither C nor C++ requires that a compiler supports NaN, but IEEE754 does.
It isn't only inf and NaN that prevent the optimization there, it's also the sign - 0.0 * something negative is -0.0, otherwise it's 0.0, so you actually have to compute the sign of r[0]*r[1].