1/*
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/**
25 * @test
26 * @bug 6930043
27 * @summary C2: SIGSEGV in javasoft.sqe.tests.lang.arr017.arr01702.arr01702.loop_forw(II)I
28 *
29 * @run main compiler.c2.Test6930043
30 */
31
32package compiler.c2;
33
34public class Test6930043 {
35    int[] a;
36    int idx;
37
38    public int loop_back(int i, int i_0_) {
39        int i_1_ = 0;
40        int[] is = a;
41        if (is == null) return 0;
42        for (int i_2_ = i; i_2_ >= i_0_; i_2_--)
43            i_1_ += is[idx = i_2_];
44        return i_1_;
45    }
46
47    public int loop_forw(int start, int end) {
48        int result = 0;
49        int[] is = a;
50        if (is == null) return 0;
51        for (int index = start; index < end; index++)
52            result += is[index];
53            // result += is[idx = index];
54        return result;
55    }
56
57    public static void main(String[] strings) {
58        Test6930043 var_Test6930043 = new Test6930043();
59        var_Test6930043.a = new int[1000000];
60        var_Test6930043.loop_forw(10, 999990);
61        var_Test6930043.loop_forw(10, 999990);
62        for (int i = 0; i < 3; i++) {
63            try {
64                if (var_Test6930043.loop_forw(-1, 999990) != 0) throw new InternalError();
65            } catch (ArrayIndexOutOfBoundsException e) { }
66        }
67        var_Test6930043.loop_back(999990, 10);
68        var_Test6930043.loop_back(999990, 10);
69        for (int i = 0; i < 3; i++) {
70            try {
71                if (var_Test6930043.loop_back(999990, -1) != 0) throw new InternalError();
72            } catch (ArrayIndexOutOfBoundsException e) { }
73        }
74    }
75}
76