Skip to content

Commit c7cd754

Browse files
committed
C++: Add testcase demonstrating false positive from conversions.
1 parent 474b337 commit c7cd754

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-190/semmle/ComparisonWithWiderType/ComparisonWithWiderType.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
| test3.cpp:6:8:6:71 | ... < ... | Comparison between $@ of type unsigned char and $@ of wider type int. | test3.cpp:5:34:5:38 | small | small | test3.cpp:6:42:6:70 | ... - ... | ... - ... |
12
| test.c:4:14:4:18 | ... < ... | Comparison between $@ of type char and $@ of wider type int. | test.c:3:7:3:7 | c | c | test.c:2:17:2:17 | x | x |
23
| test.c:9:14:9:18 | ... > ... | Comparison between $@ of type char and $@ of wider type int. | test.c:8:7:8:7 | c | c | test.c:7:17:7:17 | x | x |
34
| test.c:14:14:14:18 | ... < ... | Comparison between $@ of type short and $@ of wider type int. | test.c:13:8:13:8 | s | s | test.c:12:17:12:17 | x | x |
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
void test_issue_5850(unsigned char small, unsigned int large1) {
22
for(; small < static_cast<unsigned char>(large1 - 1); small++) { } // GOOD
3-
}
3+
}
4+
5+
void test_widening(unsigned char small, char large) {
6+
for(; small < static_cast<unsigned int>(static_cast<short>(large) - 1); small++) { } // GOOD [FALSE POSITIVE]
7+
}

0 commit comments

Comments
 (0)