Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bbeea45

Browse files
committed
C++: Add test with widening of binary Expr
1 parent 297f1c7 commit bbeea45

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,12 @@
582582
| test.c:635:9:635:10 | ss | -32768 |
583583
| test.c:638:7:638:8 | ss | -32768 |
584584
| test.c:639:9:639:10 | ss | -1 |
585+
| test.c:645:8:645:8 | s | -2147483648 |
586+
| test.c:645:15:645:15 | s | 0 |
587+
| test.c:645:23:645:23 | s | 0 |
588+
| test.c:646:18:646:18 | s | 0 |
589+
| test.c:646:22:646:22 | s | 0 |
590+
| test.c:647:9:647:14 | result | 0 |
585591
| test.cpp:10:7:10:7 | b | -2147483648 |
586592
| test.cpp:11:5:11:5 | x | -2147483648 |
587593
| test.cpp:13:10:13:10 | x | -2147483648 |

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,4 +638,12 @@ void two_bounds_from_one_test(short ss, unsigned short us) {
638638
if (ss + 1 < sizeof(int)) {
639639
out(ss); // -1 .. 2
640640
}
641+
}
642+
643+
void widen_recursive_expr() {
644+
int s;
645+
for (s = 0; s < 10; s++) {
646+
int result = s + s; // 0 .. 9 [BUG: upper bound is 15 due to widening]
647+
out(result); // 0 .. 18 [BUG: upper bound is 30 due to widening]
648+
}
641649
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,12 @@
582582
| test.c:635:9:635:10 | ss | 32767 |
583583
| test.c:638:7:638:8 | ss | 32767 |
584584
| test.c:639:9:639:10 | ss | 2 |
585+
| test.c:645:8:645:8 | s | 2147483647 |
586+
| test.c:645:15:645:15 | s | 127 |
587+
| test.c:645:23:645:23 | s | 15 |
588+
| test.c:646:18:646:18 | s | 15 |
589+
| test.c:646:22:646:22 | s | 15 |
590+
| test.c:647:9:647:14 | result | 30 |
585591
| test.cpp:10:7:10:7 | b | 2147483647 |
586592
| test.cpp:11:5:11:5 | x | 2147483647 |
587593
| test.cpp:13:10:13:10 | x | 2147483647 |

0 commit comments

Comments
 (0)