http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31119



--- Comment #9 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-10-20 
15:43:13 UTC ---

> can someone fortran aware please double-check that the tests

>

>    * gfortran.dg/bounds_check_9.f90: New test.

>    * gfortran.dg/bounds_check_fail_2.f90: New test.

>

> do not contain out of bounds access? ...



AFAICT the only difference (ignoring spaces) between the two tests is the line



   call sub((/4/))



in the second test.

So there is no out of bounds access for the first test, but in the second one

the call to sub((/4/)) in which an array of length 1 is copied in an array of

length 2, gives an out of bounds access triggering the error:



Fortran runtime error: Array bound mismatch for dimension 1 of array 'ivec'

(1/2)



when compiled with -fbounds-check.



IMO these tests are a misuse of the elemental subroutine set_optional in the

subroutine sub. The test being valid only if sub is called without argument or

with an array of length 2.



>From the 2008 standard



12.8.3 Elemental subroutine actual arguments



An elemental subroutine has only scalar dummy arguments, but may have array

actual arguments. 



In a reference to an elemental subroutine, either all actual arguments shall be

scalar, or all actual arguments corresponding to INTENT (OUT) and INTENT

(INOUT) dummy arguments shall be arrays of the same shape and the remaining

actual arguments shall be conformable with them. 



In the case that the actual arguments corresponding to INTENT (OUT) and INTENT

(INOUT) dummy arguments are arrays, the values of the elements, if any, of the

results are the same as would be obtained if the subroutine had been applied

separately, in array element order, to corresponding elements of each array

actual argument.

Reply via email to