https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64107

            Bug ID: 64107
           Summary: [F95] Pure function as array size
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxcoudert at gcc dot gnu.org

Let's consider the code below, which uses a pure function for size of arrays.
This is not allowed for the main program or a module array, as per Fortran
2008's C531:

"An explicit-shape-spec whose bounds are not constant expressions shall appear
only in a subprogram, derived type definition, BLOCK construct, or interface
body."

So we should reject x2 and x4. This should already be handled in
resolve.c:resolve_fl_variable(), but apparently it does not work.

Right now, we incorrectly accept x4, and x2 makes the compiler ICE.


!!!!!!!!!!!!!!!!!!!!!!!!!!!
module m1
contains
  pure integer function foo()
    foo = 2
  end function
end module

subroutine test
  use m1
  integer :: x1(foo())
end subroutine

module m
  use m1
  integer :: x2(foo())
contains
  subroutine sub
    integer :: x3(foo())
  end subroutine
end module

program p
  use m1
  integer :: x4(foo())
end program
!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reply via email to