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

Skip to content

Commit 7204e13

Browse files
committed
[CPP-434] Address comments re .cpp test cases.
1 parent f964fe8 commit 7204e13

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ bool cannotHoldAnotherUInt(int n1, unsigned int delta) {
2929
}
3030

3131
bool shortShort1(unsigned short n1, unsigned short delta) {
32-
// clang 8.0.0 -O2: deleted
33-
// gcc 9.2 -O2: deleted
34-
// msvc 19.22 /O2: not deleted
35-
return n1 + delta < n1; // GOOD: always false, but will never overflow
32+
33+
// BAD [BadAdditionOverflowCheck.ql]
34+
// GOOD [SigneOverflowCheck.ql]: Test always fails, but will never overflow.
35+
return n1 + delta < n1;
3636
}
3737

3838
bool shortShort2(unsigned short n1, unsigned short delta) {
@@ -107,10 +107,10 @@ bool multipleCasts(char x) {
107107
}
108108

109109
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: cannot overflow
110+
111+
// BAD [BadAdditionOverflowCheck.ql]
112+
// GOOD [SigneOverflowCheck.ql]: Test always fails, but will never overflow.
113+
return (int)(unsigned short)(x + '1') < (int)(unsigned short)x;
114114
}
115115

116116
int does_it_overflow(int n1, unsigned short delta) {

0 commit comments

Comments
 (0)