Multiply by 0 optimization

后端 未结 2 407
囚心锁ツ
囚心锁ツ 2021-01-07 20:42

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

2条回答
  •  借酒劲吻你
    2021-01-07 20:53

    Depends on whether the compiler implements IEEE754. Neither C nor C++ requires that a compiler supports NaN, but IEEE754 does.

提交回复
热议问题