Skip to content

Commit 1999a4d

Browse files
committed
cbmc-library/Float* cleanup: rename or move to cbmc/
In cbmc-library/, we organise regression tests by the name of the library function they are exercising. Rename these tests with the library function they exercise. For those not focussing on library functions, move them to cbmc/ instead. As those tests are also run past the cprover SMT solver, three tests newly demonstrated issues in the SMT back-end.
1 parent 1ae3028 commit 1999a4d

File tree

33 files changed

+162
-300
lines changed

33 files changed

+162
-300
lines changed

regression/cbmc-library/Float-div1-refine/main.c

Lines changed: 0 additions & 53 deletions
This file was deleted.

regression/cbmc-library/Float-div1/main.c

Lines changed: 0 additions & 53 deletions
This file was deleted.

regression/cbmc-library/Float-flags-no-simp1/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/cbmc-library/Float-no-simp8/main.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

regression/cbmc-library/Float-to-double1/main.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

regression/cbmc-library/Float-to-double1/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/cbmc-library/Float21/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/cbmc-library/Float_lib1/main.c

Lines changed: 0 additions & 55 deletions
This file was deleted.

regression/cbmc-library/Float_lib1/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/cbmc-library/Float_lib2/main.c

Lines changed: 0 additions & 33 deletions
This file was deleted.

regression/cbmc-library/Float_lib2/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,55 @@
11
#include <assert.h>
2+
#include <float.h>
23
#include <math.h>
34

45
int main()
56
{
6-
__builtin_isinf();
7-
assert(0);
8-
return 0;
7+
double xxx;
8+
9+
// Visual Studio needs to be 2013 onwards
10+
#if defined(_MSC_VER) && !defined(__CYGWIN__) && _MSC_VER < 1800
11+
12+
// see http://www.johndcook.com/math_h.html
13+
14+
#else
15+
assert(fpclassify(DBL_MAX + DBL_MAX) == FP_INFINITE);
16+
assert(fpclassify(0 * (DBL_MAX + DBL_MAX)) == FP_NAN);
17+
assert(fpclassify(1.0) == FP_NORMAL);
18+
assert(fpclassify(DBL_MIN) == FP_NORMAL);
19+
assert(fpclassify(DBL_MIN / 2) == FP_SUBNORMAL);
20+
assert(fpclassify(-0.0) == FP_ZERO);
21+
#endif
22+
23+
#if !defined(__clang__) && defined(__GNUC__)
24+
assert(__builtin_fpclassify(0, 1, 2, 3, 4, DBL_MAX + DBL_MAX) == 1);
25+
assert(__builtin_fpclassify(0, 1, 2, 3, 4, 0 * (DBL_MAX + DBL_MAX)) == 0);
26+
assert(__builtin_fpclassify(0, 1, 2, 3, 4, 1.0) == 2);
27+
assert(__builtin_fpclassify(0, 1, 2, 3, 4, DBL_MIN) == 2);
28+
assert(__builtin_fpclassify(0, 1, 2, 3, 4, DBL_MIN / 2) == 3);
29+
assert(__builtin_fpclassify(0, 1, 2, 3, 4, -0.0) == 4);
30+
31+
assert(__builtin_isinf(DBL_MAX + DBL_MAX) == 1);
32+
assert(__builtin_isinf(0.0) == 0);
33+
assert(__builtin_isinf(-(DBL_MAX + DBL_MAX)) == 1);
34+
35+
assert(__builtin_isinf_sign(DBL_MAX + DBL_MAX) == 1);
36+
assert(__builtin_isinf_sign(0.0) == 0);
37+
assert(__builtin_isinf_sign(-(DBL_MAX + DBL_MAX)) == -1);
38+
39+
// these are compile-time
40+
_Static_assert(
41+
__builtin_fpclassify(0, 1, 2, 3, 4, -0.0) == 4,
42+
"__builtin_fpclassify is constant");
43+
44+
_Static_assert(__builtin_isnormal(DBL_MIN), "__builtin_isnormal is constant");
45+
46+
_Static_assert(!__builtin_isinf(0.0), "__builtin_isinf is constant");
47+
48+
_Static_assert(
49+
__builtin_isinf_sign(0.0) == 0, "__builtin_isinf_sign is constant");
50+
51+
#endif
52+
53+
assert(signbit(-1.0) != 0);
54+
assert(signbit(1.0) == 0);
955
}

regression/cbmc-library/__builtin_isinf-01/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
KNOWNBUG
1+
CORE
22
main.c
3-
--pointer-check --bounds-check
3+
--floatbv
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

0 commit comments

Comments
 (0)