User account creation filtered due to spam.

Bug 47506 - [OOP][Fortran 90+] Assumed-size array checks (polymorphic and component)
Summary: [OOP][Fortran 90+] Assumed-size array checks (polymorphic and component)
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: accepts-invalid, diagnostic
Depends on:
Reported: 2011-01-28 08:48 UTC by Tobias Burnus
Modified: 2014-03-22 19:05 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2014-03-22 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2011-01-28 08:48:44 UTC
a) Fortran 90 and later:

Aleks noted at 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)
    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 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)

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

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

 * * *

Bob believes both are invalid - and covered by:

      An assumed-size array ( 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.