This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ASSOCIATE and array bounds checking


If I understand ASSOCIATE correctly, then the following 
code should issue a runtime error for an array mismatch.

program co_assoc

  implicit none

  integer, allocatable :: a(:)

  allocate (a(2))

  a = [1,2]
  write(*, '(5(I0,1X))') a, size(a), lbound(a), ubound(a)
 
  associate (i => a)
    i = i + 41
    write(*, '(5(I0,1X))') i, size(i), lbound(i), ubound(i)
    !
    ! i has dimensions i(1:2).  Array mismatch expression?
    ! 
    i = [1, 2, 3]
    write(*, '(5(I0,1X))') i, size(i), lbound(i), ubound(i)
  end associate

end program co_assoc

laptop-kargl:kargl[222] gfc -o z b.f90 && ./z
1 2 2 1 2
42 43 2 1 2
43 45 2 1 2

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]