File tree Expand file tree Collapse file tree
cpp/ql/test/query-tests/Likely Bugs/Arithmetic/BadAdditionOverflowCheck Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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. |
Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff line change 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. |
File renamed without changes.
You can’t perform that action at this time.
0 commit comments