Skip to content

Commit

Permalink
C library: model __builtin_powi{,f,l}
Browse files Browse the repository at this point in the history
These GCC built-ins are modelled by implementing pow{,f,l} specialised
to integral exponents (where multiple failure cases cannot occur).
  • Loading branch information
tautschnig committed Feb 12, 2024
1 parent 9c7bccc commit a0744d7
Show file tree
Hide file tree
Showing 7 changed files with 418 additions and 0 deletions.
11 changes: 11 additions & 0 deletions regression/cbmc-library/__builtin_powi-01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <assert.h>
#include <math.h>

double __builtin_powi(double, int);

int main()
{
double four = __builtin_powi(2.0, 2);
assert(four > 3.999 && four < 4.345);
return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc-library/__builtin_powi-01/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--float-overflow-check --nan-check
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
11 changes: 11 additions & 0 deletions regression/cbmc-library/__builtin_powif-01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <assert.h>
#include <math.h>

float __builtin_powif(float, int);

int main()
{
float four = __builtin_powif(2.0f, 2);
assert(four > 3.999f && four < 4.345f);
return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc-library/__builtin_powif-01/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--float-overflow-check --nan-check
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
11 changes: 11 additions & 0 deletions regression/cbmc-library/__builtin_powil-01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <assert.h>
#include <math.h>

long double __builtin_powil(long double, int);

int main()
{
long double four = __builtin_powil(2.0l, 2);
assert(four > 3.999l && four < 4.345l);
return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc-library/__builtin_powil-01/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--float-overflow-check --nan-check
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
Loading

0 comments on commit a0744d7

Please sign in to comment.