The following code should tell us we have an out-of-bounds access at runtime: $ cat a.f90 subroutine foo(a) integer a(*), i i = 0 a(i) = 42 end subroutine foo program test integer x(42) call foo(x) end program test $ gfortran a.f90 -fbounds-check && ./a.out
Created attachment 13509 [details] Tentative patch for this bug Not yet fully tested, nor regtested, but it should do the deed.
Subject: Bug 31627 Author: fxcoudert Date: Tue May 22 09:27:15 2007 New Revision: 124940 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124940 Log: PR fortran/31627 * trans-array.c (gfc_trans_array_bound_check): Take extra argument to indicate whether we should check the upper bound in that dimension. (gfc_conv_array_index_offset): Check only the lower bound of the last dimension for assumed-size arrays. (gfc_conv_array_ref): Likewise. (gfc_conv_ss_startstride): Likewise. * gfortran.dg/bounds_check_7.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/bounds_check_7.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-array.c trunk/gcc/testsuite/ChangeLog
Fixed on mainline.