mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
[CPP-434] Move SignedOverflowCheck test to BadAdditionOverflowCheck directory; add additional tests.
This commit is contained in:
@@ -1 +1,3 @@
|
||||
| SignedOverflowCheck.cpp:35:9:35:23 | ... < ... | Bad overflow check. |
|
||||
| SignedOverflowCheck.cpp:113:12:113:66 | ... < ... | Bad overflow check. |
|
||||
| test.cpp:3:11:3:19 | ... < ... | Bad overflow check. |
|
||||
|
||||
@@ -98,3 +98,17 @@ int overflow12(int n) {
|
||||
// not deleted by gcc or clang
|
||||
return (n + 32 <= (unsigned)n? -1: 1); // BAD
|
||||
}
|
||||
|
||||
bool multipleCasts(char x) {
|
||||
// clang 9.0.0 -O2: deleted
|
||||
// gcc 9.2 -O2: deleted
|
||||
// msvc 19.22 /O2: deleted
|
||||
return (int)(unsigned short)x + 2 < (int)(unsigned short)x; // BAD
|
||||
}
|
||||
|
||||
bool multipleCasts2(char x) {
|
||||
// clang 9.0.0 -O2: not deleted
|
||||
// gcc 9.2 -O2: not deleted
|
||||
// msvc 19.22 /O2: not deleted
|
||||
return (int)(unsigned short)(x + '1') < (int)(unsigned short)x; // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
@@ -2,3 +2,6 @@
|
||||
| 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: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. |
|
||||
Reference in New Issue
Block a user