Files
codeql/cpp/ql/test/query-tests/Likely Bugs/Arithmetic/BadCheckOdd/test.cpp
2026-07-07 09:49:50 +01:00

16 lines
317 B
C++

int test1(int x) {
return x % 2 == 1; // $ Alert // 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; // $ Alert // BAD
}
int test4(unsigned short x) {
return x % 2 == 1; // GOOD: x is unsigned and thus non-negative.
}