Skip to content

Commit 96de90f

Browse files
Add shift tests that exhibit bug
Values >= bitwidth are not handled correctly.
1 parent 762f7df commit 96de90f

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed
753 Bytes
Binary file not shown.

jbmc/regression/jbmc/shift1/shift1.java

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,45 @@
11
class shift1
22
{
3-
public static void main(String[] args)
3+
public static void foo(int c, long x)
44
{
5-
assert (5 << 1) == 10;
6-
assert (5 >> 1) == 2;
7-
assert (-4 >> 1) == -2;
8-
assert (-4 >>> 1) == 2147483646;
5+
switch (c)
6+
{
7+
case 0:
8+
if (x == 5L) assert ((int)x << 1) == 10;
9+
break;
10+
case 1:
11+
if (x == 5L) assert ((int)x >> 1) == 2;
12+
break;
13+
case 2:
14+
if (x == -4L) assert ((int)x >> 1) == -2;
15+
break;
16+
case 3:
17+
if (x == -4L) assert ((int)x >>> 1) == 2147483646;
18+
break;
19+
case 4:
20+
if (x == 1L) assert ((int)x << 0) == 1;
21+
break;
22+
case 5:
23+
if (x == 1L) assert ((int)x << 31) == -2147483648;
24+
break;
25+
case 6:
26+
if (x == 1L) assert ((int)x << 32) == 1;
27+
break;
28+
case 7:
29+
if (x == 1L) assert ((int)x << 33) == 2;
30+
break;
31+
case 8:
32+
if (x == 1L) assert (x << 0) == 1L;
33+
break;
34+
case 9:
35+
if (x == 1L) assert (x << 63) == -9223372036854775808L;
36+
break;
37+
case 10:
38+
if (x == 1L) assert (x << 64) == 1L;
39+
break;
40+
default:
41+
if (x == 1L) assert (x << 65) == 2L;
42+
break;
43+
}
944
}
1045
}
11-

jbmc/regression/jbmc/shift1/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
CORE
2-
shift1
1+
KNOWNBUG
2+
shift1.foo
33

44
^EXIT=0$
55
^SIGNAL=0$

0 commit comments

Comments
 (0)