https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82937
Bug ID: 82937 Summary: [F03] associate non-standard bounds are lost for associating entity Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: only_for_nouse at gmx dot de Target Milestone: --- Created attachment 42580 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42580&action=edit Fortran 2003 program with associate construct The attached file compiles and links fine with gfortran 7.2 compilers. (gfortran -g -fbounds-check -O0 fortran_associate.F90) The output of the code is arr bounds are ( 1, 5)( 1, 8)(-3, 3)( 1,10) myarr bounds are ( 1, 7)( 1,10) At line 18 of file fortran_associate.F90 Fortran runtime error: Index '-3' of dimension 1 of array 'myarr' below lower bound of 1 The code uses the associate construct to associate a subarray with an associate name. The original array has non-standard array bounds -3:3, but these array bounds are not retained for the associate name, although the standard says: Within an ASSOCIATE or SELECT TYPE construct, each associating entity has the same rank and corank as its associated selector. The lower bound of each dimension is the result of the intrinsic function LBOUND applied to the corresponding dimension of selector. The upper bound of each dimension is one less than the sum of the lower bound and the extent. To my understanding, the array bounds of the selector should be retained also inside the associate construct for the associating entity.