|
|
| Bugzilla Link |
12687 |
| Version |
unspecified |
| OS |
All |
| Reporter |
LLVM Bugzilla Contributor |
| CC |
@gribozavr |
Extended Description
I recently wrote code that looked roughly like this (the isfinite and copysign expressions were spelled in other terms that didn't make the code look so obviously wrong):
#include <math.h>
#include <stdlib.h>
inline double TimeClip(double time)
{
if (!isfinite(time) || abs(time) > 8.64e15)
return NAN;
return copysign(floor(fabs(time)), time + 0.0);
}
int main()
{
TimeClip(17.0);
return 0;
}
This code's buggy in that it uses abs (int -> int) when it should have used fabs (double -> double). The compiler can't be expected to figure that out, of course. But it should be able to figure out that no |int| value will ever be greater than 8.64e15, and it should emit a tautological-compare warning just as it would if it saw any other always-true or always-false comparison.