[CPP-434] Move SignedOverflowCheck test to BadAdditionOverflowCheck directory; add additional tests.

This commit is contained in:
Ziemowit Laski
2019-10-16 14:31:11 -07:00
parent f40c21bf6e
commit fb625c12ef
4 changed files with 19 additions and 0 deletions

View File

@@ -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. |

View File

@@ -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]
}

View File

@@ -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. |