PR middle-end/77674
[official-gcc.git] / gcc / testsuite / gfortran.dg / reshape-alloc.f90
blobc4c7a0e2a8c73dcc572b42e65581c9bda497977d
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) call abort
26 resh1 = reshape(vect1,s)
27 if (resh1(1,1) /= 1.0) call abort
29 resh = reshape(vect,s)
30 if (resh(1,1) /= 1.0) call abort
32 end program tryreshape