1! { dg-do compile }
2! PR fortran/85816
3! Original code from Martin Diehl <m.diehl at mpie dot de>
4!
5! Prior to fixing the problem with the array descriptor, gfortran died with
6! Operating system error: Cannot allocate memory
7! Integer overflow in xmallocarray
8!
9program test
10  implicit none
11  real(8) :: tensor(3,3) = 4
12  integer :: grid(3) = 16
13  ! ok
14  write(6,*) spread(spread(tensor,3,grid(1)),4,grid(1))
15  ! ok (note the brackets)
16  write(6,*) spread((spread(spread(tensor,3,grid(1)),4,grid(2))),5,grid(3))
17  ! not ok
18  write(6,*) spread(spread(spread(tensor,3,grid(1)),4,grid(2)),5,grid(3))
19end program
20