Skip to content

Commit 2b5d150

Browse files
committed
C++: Test for IntMultToLong on char-typed numbers
1 parent 7f56be6 commit 2b5d150

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/IntMultToLong/IntMultToLong.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,7 @@ void use_printf(float f, double d)
8888
// ^ there's a float -> double varargs promotion here, but it's unlikely that the author anticipates requiring a double
8989
printf("%f", d * d); // safe
9090
}
91+
92+
size_t three_chars(unsigned char a, unsigned char b, unsigned char c) {
93+
return a * b * c; // at most 16581375 [FALSE POSITIVE]
94+
}

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/IntMultToLong/IntMultToLong.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
| IntMultToLong.c:61:23:61:33 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long long'. |
88
| IntMultToLong.c:63:23:63:40 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long long'. |
99
| IntMultToLong.c:75:9:75:13 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'size_t'. |
10+
| IntMultToLong.c:93:12:93:20 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'size_t'. |

0 commit comments

Comments
 (0)