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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
I believe the code is invalid.  Here a small rewrite

program bug

   implicit none

   real, target, allocatable :: a(:,:)
   allocate(a(10,10))
   a = 1.0
   print*, f(a) 

   contains

      function f(b) result(x)
         real, target, intent(in):: b(:,:)
         real, pointer :: c(:,:)
         real :: x(size(c(1,:)))
         c => b(1:2,:)
         x = c(2,:)
      end function f

end program bug


The line 'real :: x(size(c(1,:))' is referencing an
unassociated pointer.  If I add the 'integer :: n = size(c(1,:))
I get 

% gfc6 -c bug.f90
bug.f90:15:29:

          integer :: n = size(c(1,:))
                             1
Error: Deferred array 'c' at (1) is not permitted in an initialization
expression

A similar error should probably occur here.

Reply via email to