Skip to content

Commit d7afd86

Browse files
committed
C++: Add test case exposing problem with overflows for upperBound predicate
1 parent a031b2a commit d7afd86

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@
599599
| test.c:675:7:675:7 | y | -2147483648 |
600600
| test.c:684:7:684:7 | x | -2147483648 |
601601
| test.c:689:7:689:7 | x | -2147483648 |
602+
| test.c:696:8:696:8 | x | 2147483647 |
603+
| test.c:696:12:696:12 | y | 256 |
604+
| test.c:697:9:697:9 | x | 2147483647 |
605+
| test.c:698:9:698:9 | y | 256 |
602606
| test.cpp:10:7:10:7 | b | -2147483648 |
603607
| test.cpp:11:5:11:5 | x | -2147483648 |
604608
| test.cpp:13:10:13:10 | x | -2147483648 |

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,3 +689,12 @@ void test(int x) {
689689
out(x);
690690
goto label;
691691
}
692+
693+
void test_overflow() {
694+
const int x = 2147483647; // 2^31-1
695+
const int y = 256;
696+
if ((x + y) <= 512) {
697+
out(x);
698+
out(y);
699+
}
700+
}

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@
599599
| test.c:675:7:675:7 | y | 2147483647 |
600600
| test.c:684:7:684:7 | x | 2147483647 |
601601
| test.c:689:7:689:7 | x | 15 |
602+
| test.c:696:8:696:8 | x | 2147483647 |
603+
| test.c:696:12:696:12 | y | 256 |
604+
| test.c:697:9:697:9 | x | 256 |
605+
| test.c:698:9:698:9 | y | -2147483135 |
602606
| test.cpp:10:7:10:7 | b | 2147483647 |
603607
| test.cpp:11:5:11:5 | x | 2147483647 |
604608
| test.cpp:13:10:13:10 | x | 2147483647 |

0 commit comments

Comments
 (0)