Skip to content

Commit 87382d7

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 8d314eb commit 87382d7

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed
Lines changed: 7 additions & 3 deletions
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

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+
--pointer-check --bounds-check --signed-overflow-check
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
Lines changed: 3 additions & 2 deletions
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

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

src/ansi-c/cprover_builtin_headers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int __CPROVER_isunorderedd(double f, double g);
8383
// absolute value
8484
int __CPROVER_abs(int x);
8585
long int __CPROVER_labs(long int x);
86-
long int __CPROVER_llabs(long long int x);
86+
long long int __CPROVER_llabs(long long int x);
8787
double __CPROVER_fabs(double x);
8888
long double __CPROVER_fabsl(long double x);
8989
float __CPROVER_fabsf(float x);

0 commit comments

Comments
 (0)