Skip to content

Commit 448421b

Browse files
committed
consolidate integer overflow tests in one directory
This moves the tests that relate to integer overflow checking into one directory.
1 parent 07ae494 commit 448421b

16 files changed

+35
-31
lines changed

regression/cbmc/Overflow_Multiplication1/falsealarm.c

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

regression/cbmc/Overflow_Leftshift1/test-c89.desc renamed to regression/cbmc/overflow/leftshift_overflow-c89.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
main.c
2+
leftshift_overflow.c
33
--signed-overflow-check --c89
44
^EXIT=10$
55
^SIGNAL=0$

regression/cbmc/Overflow_Leftshift1/test-c99.desc renamed to regression/cbmc/overflow/leftshift_overflow-c99.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
main.c
2+
leftshift_overflow.c
33
--signed-overflow-check --c99
44
^EXIT=10$
55
^SIGNAL=0$

regression/cbmc/Overflow_Leftshift1/main.c renamed to regression/cbmc/overflow/leftshift_overflow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ int main()
88
unsigned r = x << ((sizeof(unsigned) - 1) * 8 + 1);
99

1010
// signed, owing to promotion, and cannot overflow
11-
r=x << ((sizeof(unsigned)-1)*8-1);
11+
r = x << ((sizeof(unsigned) - 1) * 8 - 1);
1212

1313
// unsigned
14-
r=(unsigned)x << ((sizeof(unsigned)-1)*8);
14+
r = (unsigned)x << ((sizeof(unsigned) - 1) * 8);
1515

1616
// negative value or zero, not an overflow
1717
int s = -x << ((sizeof(int) - 1) * 8);
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
int main() {
1+
int main()
2+
{
23
signed int i, j;
34

4-
i=j;
5+
i = j;
56

67
i++;
78
}

regression/cbmc/Overflow_Addition1/test.desc renamed to regression/cbmc/overflow/signed_addition_overflow1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
main.c
2+
signed_addition_overflow1.c
33
--signed-overflow-check
44
^EXIT=10$
55
^SIGNAL=0$

regression/cbmc/Overflow_Addition2/test.desc renamed to regression/cbmc/overflow/signed_addition_overflow2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
main.c
2+
signed_addition_overflow2.c
33
--signed-overflow-check
44
^EXIT=10$
55
^SIGNAL=0$

regression/cbmc/Overflow_Addition3/test.desc renamed to regression/cbmc/overflow/signed_addition_overflow3.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
main.c
2+
signed_addition_overflow3.c
33
--signed-overflow-check --conversion-check
44
^EXIT=10$
55
^SIGNAL=0$

regression/cbmc/Overflow_Addition4/test.desc renamed to regression/cbmc/overflow/signed_addition_overflow4.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
main.c
2+
signed_addition_overflow4.c
33
--signed-overflow-check --conversion-check
44
^EXIT=10$
55
^SIGNAL=0$
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// From Cousot's FMSD paper
2+
3+
void main()
4+
{
5+
int x, y, _x, _y;
6+
7+
x = _x;
8+
y = _y;
9+
10+
if(
11+
(-4681 < y) && (y < 4681) && (x < 32767) && (-32767 < x) &&
12+
((7 * y * y - 1) == x * x))
13+
{
14+
y = 1 / x;
15+
}
16+
}

regression/cbmc/Overflow_Subtraction1/test.desc renamed to regression/cbmc/overflow/signed_multiplication1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
main.c
2+
signed_multiplication1.c
33
--signed-overflow-check
44
^EXIT=0$
55
^SIGNAL=0$
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
#define INT_MIN (-1<<(sizeof(int)*8-1))
1+
#define INT_MIN (-1 << (sizeof(int) * 8 - 1))
22

33
int main()
44
{
55
int a, b, neg;
66

77
// this should not overflow, even not for a=INT_MIN
8-
b=a-a;
8+
b = a - a;
99

1010
// this should also not overflow as long as pos<0
11-
if(neg<0)
12-
b=neg-INT_MIN;
11+
if(neg < 0)
12+
b = neg - INT_MIN;
1313

1414
int x, y, z;
1515

16-
x = INT_MIN+1;
16+
x = INT_MIN + 1;
1717
y = INT_MIN;
18-
z = x-y; // neither
18+
z = x - y; // neither
1919
}

regression/cbmc/Overflow_Multiplication1/test.desc renamed to regression/cbmc/overflow/signed_subtraction1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
2-
falsealarm.c
2+
signed_subtraction1.c
33
--signed-overflow-check
44
^EXIT=0$
55
^SIGNAL=0$

0 commit comments

Comments
 (0)