infer_clone/infer/tests/codetoanalyze/java/topl/compareArgs/CompareArgs.java

31 lines
603 B

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
class CompareArgs {
static int max(int[] a, int i, int k) {
int m = a[i];
for (int j = i + 1; j < k; ++j) {
m = Math.max(m, a[j]);
}
return m;
}
static void aBad() {
int[] a = new int[10];
int x = max(a, 2, 2);
}
static void bOk() {
int[] a = new int[10];
int x = max(a, 2, 3);
}
static void cBad() {
int[] a = new int[10];
int x = max(a, 2, 1);
}
}