Bug 47506

Summary: [OOP][Fortran 90+] Assumed-size array checks (polymorphic and component)
Product: gcc Reporter: Tobias Burnus <burnus>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: janus
Priority: P3 Keywords: accepts-invalid, diagnostic
Version: 4.6.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2021-12-17 00:00:00

Description Tobias Burnus 2011-01-28 08:48:44 UTC
===================================================
a) Fortran 90 and later:
===================================================

Aleks noted at http://j3-fortran.org/pipermail/j3/2011-January/004154.html the gfortran misses a diagnostic for the following program.

Ifort prints:
  The upper bound shall not be omitted in the last dimension of a reference
  to an assumed size array.   [X]
       call sub2(x%i)
-----------------^

NAG has: Error: line 16: Invalid appearance of assumed-size array name X

Pathscale/open64 have:
  This whole array reference of an assumed-size array is not allowed.

program test
    type :: t
       integer :: i
       real :: r
    end type
    type(t) :: x(10)
    call sub1(x)
contains
    subroutine sub1(x)
       type(t) :: x(*)
       call sub2(x%i)  ! WRONG: Should be, e.g., x(:10)%i
    end subroutine
    subroutine sub2(x)
       integer :: x(*)
    end subroutine
end program

===================================================
b) [OOP] Fortran 2003 and later
===================================================

Bill noted at http://j3-fortran.org/pipermail/j3/2011-January/004148.html in the same thread that the standard (nor gfortran) reject:

  assumed-size poly actual -> non-poly dummy

although for most compilers (but IBM's?) it will not work. Sketched example:

subroutine before(w)
use typedef
! Interface for A here
type(T) :: w(*) ! no descriptor here - size not known
call A(w)
end

subroutine A (x)
use typedef ! types T and extensions defined in here
class(T) :: x(*)
...
call B(x)
...
end

subroutine B(y)
use typedef
type(T) :: y(*)


 * * *

Bob believes both are invalid - and covered by:

      An assumed-size array (5.3.6.5) is permitted to appear as a whole
      array in an executable construct or specification expression only
      as an actual argument in a procedure reference that does not
      require the shape.
Comment 1 Dominique d'Humieres 2014-03-22 19:05:11 UTC
Wrong link. No error when compiling the test in a with r208766.