Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb625c1

Browse files
committed
[CPP-434] Move SignedOverflowCheck test to BadAdditionOverflowCheck directory; add additional tests.
1 parent f40c21b commit fb625c1

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
| SignedOverflowCheck.cpp:35:9:35:23 | ... < ... | Bad overflow check. |
2+
| SignedOverflowCheck.cpp:113:12:113:66 | ... < ... | Bad overflow check. |
13
| test.cpp:3:11:3:19 | ... < ... | Bad overflow check. |

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/SignedOverflowCheck/SignedOverflowCheck.cpp renamed to cpp/ql/test/query-tests/Likely Bugs/Arithmetic/BadAdditionOverflowCheck/SignedOverflowCheck.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,17 @@ int overflow12(int n) {
9898
// not deleted by gcc or clang
9999
return (n + 32 <= (unsigned)n? -1: 1); // BAD
100100
}
101+
102+
bool multipleCasts(char x) {
103+
// clang 9.0.0 -O2: deleted
104+
// gcc 9.2 -O2: deleted
105+
// msvc 19.22 /O2: deleted
106+
return (int)(unsigned short)x + 2 < (int)(unsigned short)x; // BAD
107+
}
108+
109+
bool multipleCasts2(char x) {
110+
// clang 9.0.0 -O2: not deleted
111+
// gcc 9.2 -O2: not deleted
112+
// msvc 19.22 /O2: not deleted
113+
return (int)(unsigned short)(x + '1') < (int)(unsigned short)x; // GOOD [FALSE POSITIVE]
114+
}

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/SignedOverflowCheck/SignedOverflowCheck.expected renamed to cpp/ql/test/query-tests/Likely Bugs/Arithmetic/BadAdditionOverflowCheck/SignedOverflowCheck.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
| SignedOverflowCheck.cpp:18:12:18:26 | ... < ... | Testing for signed overflow may produce undefined results. |
33
| SignedOverflowCheck.cpp:35:9:35:23 | ... < ... | Testing for signed overflow may produce undefined results. |
44
| SignedOverflowCheck.cpp:99:10:99:30 | ... <= ... | Testing for signed overflow may produce undefined results. |
5+
| SignedOverflowCheck.cpp:106:12:106:62 | ... < ... | Testing for signed overflow may produce undefined results. |
6+
| SignedOverflowCheck.cpp:113:12:113:66 | ... < ... | Testing for signed overflow may produce undefined results. |
7+
| test.cpp:3:11:3:19 | ... < ... | Testing for signed overflow may produce undefined results. |

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/SignedOverflowCheck/SignedOverflowCheck.qlref renamed to cpp/ql/test/query-tests/Likely Bugs/Arithmetic/BadAdditionOverflowCheck/SignedOverflowCheck.qlref

File renamed without changes.

0 commit comments

Comments
 (0)