Skip to content

Commit d984199

Browse files
committed
__CPROVER_llabs returns a long long
Fixes the declaration in builtin_headers.h. Type checking actually ignored this declaration and would always generate the expression of the correct type.
1 parent fdc7ba5 commit d984199

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#include <assert.h>
2-
#include <stdlib.h>
2+
3+
#include <limits.h>
4+
5+
#ifndef __GNUC__
6+
long long __builtin_llabs(long long);
7+
#endif
38

49
int main()
510
{
6-
__builtin_llabs();
7-
assert(0);
11+
assert(__builtin_llabs(LLONG_MIN + 1) == LLONG_MAX);
812
return 0;
913
}

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

+2-2
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+
--pointer-check --bounds-check --signed-overflow-check
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#include <assert.h>
22
#include <stdlib.h>
33

4+
#include <limits.h>
5+
46
int main()
57
{
6-
llabs();
7-
assert(0);
8+
assert(llabs(LLONG_MIN + 1) == LLONG_MAX);
89
return 0;
910
}

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

+2-2
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+
--pointer-check --bounds-check --signed-overflow-check
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

src/ansi-c/cprover_builtin_headers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int __CPROVER_isunorderedd(double f, double g);
8484
// absolute value
8585
int __CPROVER_abs(int x);
8686
long int __CPROVER_labs(long int x);
87-
long int __CPROVER_llabs(long long int x);
87+
long long int __CPROVER_llabs(long long int x);
8888
double __CPROVER_fabs(double x);
8989
long double __CPROVER_fabsl(long double x);
9090
float __CPROVER_fabsf(float x);

0 commit comments

Comments
 (0)