Files
codeql/cpp/ql/test/query-tests/Likely Bugs/Arithmetic/BadCheckOdd/test.cpp
2018-08-02 17:53:23 +01:00

16 lines
295 B
C++

int test1(int x) {
return x % 2 == 1; // BAD
}
int test2(unsigned int x) {
return x % 2 == 1; // GOOD: x is unsigned and thus non-negative.
}
int test3(short x) {
return x % 2 == 1; // BAD
}
int test4(unsigned short x) {
return x % 2 == 1; // GOOD: x is unsigned and thus non-negative.
}