mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
[CPP-434] Change query so it flags overflows that were cast to unsigned.
This commit is contained in:
@@ -39,7 +39,7 @@ bool shortShort2(unsigned short n1, unsigned short delta) {
|
||||
// clang 8.0.0 -O2: not deleted
|
||||
// gcc 9.2 -O2: not deleted
|
||||
// msvc 19.22 /O2: not deleted
|
||||
return (unsigned short)(n1 + delta) < n1; // GOOD
|
||||
return (unsigned short)(n1 + delta) < n1; // BAD: n1 + delta overflow undefined
|
||||
}
|
||||
|
||||
/* Distinguish `varname` from `ptr->varname` and `obj.varname` */
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
| SignedOverflowCheck.cpp:8:12:8:22 | ... < ... | Testing for signed overflow may produce undefined results. |
|
||||
| SignedOverflowCheck.cpp:18:12:18:26 | ... < ... | Testing for signed overflow may produce undefined results. |
|
||||
| SignedOverflowCheck.cpp:35:9:35:23 | ... < ... | Testing for signed overflow may produce undefined results. |
|
||||
| SignedOverflowCheck.cpp:42:9:42:41 | ... < ... | Testing for signed overflow may produce undefined results. |
|
||||
| SignedOverflowCheck.cpp:99:10:99:30 | ... <= ... | Testing for signed overflow may produce undefined results. |
|
||||
| SignedOverflowCheck.cpp:106:12:106:62 | ... < ... | Testing for signed overflow may produce undefined results. |
|
||||
| SignedOverflowCheck.cpp:113:12:113:66 | ... < ... | Testing for signed overflow may produce undefined results. |
|
||||
| test.cpp:3:11:3:19 | ... < ... | Testing for signed overflow may produce undefined results. |
|
||||
| test.cpp:8:11:8:37 | ... < ... | Testing for signed overflow may produce undefined results. |
|
||||
|
||||
@@ -5,7 +5,7 @@ bool checkOverflow1(unsigned short a, unsigned short b) {
|
||||
|
||||
// Test for BadAdditionOverflowCheck.
|
||||
bool checkOverflow2(unsigned short a, unsigned short b) {
|
||||
return ((unsigned short)(a + b) < a); // GOOD: explicit cast
|
||||
return ((unsigned short)(a + b) < a); // BAD: a + b overflow undefined
|
||||
}
|
||||
|
||||
// Test for PointlessSelfComparison.
|
||||
|
||||
Reference in New Issue
Block a user