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 /** 26 * @test 27 * @bug 6930043 28 * @summary C2: SIGSEGV in javasoft.sqe.tests.lang.arr017.arr01702.arr01702.loop_forw(II)I 29 * 30 * @run main Test6930043 31 */ 32 33 import java.io.PrintStream; 34 35 public class Test6930043 { 36 int[] a; 37 int idx; 38 loop_back(int i, int i_0_)39 public int loop_back(int i, int i_0_) { 40 int i_1_ = 0; 41 int[] is = a; 42 if (is == null) return 0; 43 for (int i_2_ = i; i_2_ >= i_0_; i_2_--) 44 i_1_ += is[idx = i_2_]; 45 return i_1_; 46 } 47 loop_forw(int start, int end)48 public int loop_forw(int start, int end) { 49 int result = 0; 50 int[] is = a; 51 if (is == null) return 0; 52 for (int index = start; index < end; index++) 53 result += is[index]; 54 // result += is[idx = index]; 55 return result; 56 } 57 main(String[] strings)58 public static void main(String[] strings) { 59 Test6930043 var_Test6930043 = new Test6930043(); 60 var_Test6930043.a = new int[1000000]; 61 var_Test6930043.loop_forw(10, 999990); 62 var_Test6930043.loop_forw(10, 999990); 63 for (int i = 0; i < 3; i++) { 64 try { 65 if (var_Test6930043.loop_forw(-1, 999990) != 0) throw new InternalError(); 66 } catch (ArrayIndexOutOfBoundsException e) { } 67 } 68 var_Test6930043.loop_back(999990, 10); 69 var_Test6930043.loop_back(999990, 10); 70 for (int i = 0; i < 3; i++) { 71 try { 72 if (var_Test6930043.loop_back(999990, -1) != 0) throw new InternalError(); 73 } catch (ArrayIndexOutOfBoundsException e) { } 74 } 75 } 76 } 77