mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
Merge pull request #2085 from aschackmull/java/overflow-check-fp
Java: Add another overflow check pattern to UselessComparisonTest.
This commit is contained in:
@@ -121,6 +121,26 @@ public class A {
|
||||
}
|
||||
}
|
||||
|
||||
static final long VAL = 100L;
|
||||
|
||||
long overflowAwareIncrease(long x) {
|
||||
if (x + VAL > x) {
|
||||
return x + VAL;
|
||||
} else {
|
||||
overflow();
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
long overflowAwareDecrease(long x) {
|
||||
if (x - VAL < x) {
|
||||
return x - VAL;
|
||||
} else {
|
||||
overflow();
|
||||
return Long.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
void overflow() { }
|
||||
|
||||
void unreachableCode() {
|
||||
|
||||
Reference in New Issue
Block a user