Open
Description
I run cbmc
on the code attached (part of my graphic library) that should be SAFE.
However cbmc
returns assertion Q_rsqrt(f) > 0: FAILURE
.
Why?
#include <assert.h>
#include <math.h>
float nondet_float (void);
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y;
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) );
return y;
}
int main (void) {
float f = nondet_float();
// Everything in this range hits the bug
__CPROVER_assume(f < +INFINITY);
__CPROVER_assume(f > 0.0f);
// Should pass ass 1/sqrt(f) is always > 0 when f > 0
assert(Q_rsqrt(f) > 0);
return 1;
}
CBMC version: 5.80
Operating system: MacOS
Exact command line resulting in the issue: cbmc main.c
What behaviour did you expect: Verification SUCCESS
What happened instead: Verification FAILURE