2018-03-15 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / reshape-alloc.f90
blobbb395c53f2f5409e40363604182f9306ef1b6c28
1 ! { dg-do run }
2 ! PR 20074: This used to segfault at runtime.
3 ! Test case contributed by "Alfredo Buttari" <pitagoras@tin.it>
5 program tryreshape
7 integer,allocatable :: vect1(:),resh1(:,:)
8 integer,pointer :: vect(:),resh(:,:)
9 integer :: vect2(2*4), resh2(2,4)
10 integer :: r, s(2)
12 r=2; nb=4
14 s(:)=(/r,nb/)
16 allocate(vect(nb*r),vect1(nb*r))
17 allocate(resh(r,nb),resh1(r,nb))
19 vect =1
20 vect1=1
21 vect2=1
23 resh2 = reshape(vect2,s)
24 if (resh2(1,1) /= 1.0) STOP 1
26 resh1 = reshape(vect1,s)
27 if (resh1(1,1) /= 1.0) STOP 2
29 resh = reshape(vect,s)
30 if (resh(1,1) /= 1.0) STOP 3
32 end program tryreshape