------- Comment #1 from burnus at gcc dot gnu dot org 2008-01-15 19:30 ------- Confirmed. Your bugreport was there even before mine, but since my contains a link to the patch I mark yours as duplicate.
Thanks for finding the bug. > This diagnostic is (a) misleading - b is NOT an assumed-shape array, > and (b) incorrect. I believe the code is standard conforming Fortran > under the provision allowing an array element to be passed to an array > dummy argument. (a) is true: It is an array of deferred shape and thus the error message is indeed wrong. (Both from the message and from showing an error message at all.) Otherwise the error message is correct: You may not pass an element of an assumed-shape array (or a pointer) to an assumed-shape dummy argument. The reason is that there is no reason for such arrays to be contiguous in memory. Assume for instance: subroutine func(a) integer :: a(:) call func2(a(4)) contains subroutine func2(b) integer :: b(5) ! or "integer :: b(*)" end subroutine func2 end subroutine func If one now calls "func" as "call func(array(1:100:20))", the array A is not contiguous in memory because of the strides. Passing "A(4)" now to func2 poses a problem: b(2) is outside of the array "A" (though within array "array"). In order to prevent this problem, the standard does not allow to pass elements of assumed-shaped arrays or pointers as actual argument to array dummy arguments. The bug is only that my patch accidentally also rejected arrays with deferred shape (as your example); since here the allocation is in the same subroutine as the call, the memory is contiguous and there is no problem. (In principle, the array "A" could be copied into a temporary array with no strides, but this is not what the standard mandates here. If one calls "func2" as "call func2(a(11:15))" this is actually done so - if "A" has strides.) *** This bug has been marked as a duplicate of 34796 *** -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |DUPLICATE http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34788