1! { dg-do run }
2! PR52012 - with realloc_lhs active(ie. default condition) the
3! offset was wrongly calculated for a, after assignment.
4!
5! Reported by Reinhold Bader and Tobias Burnus  <burnus@gcc.gnu.org>
6!
7program gf
8  implicit none
9  real, allocatable :: a(:,:,:)
10  real, parameter :: zero = 0.0, one = 1.0
11  real :: b(3,4,5) = zero
12  b(1,2,3) = one
13  allocate (a(size (b, 3), size (b, 2), size (b, 1)))
14  a = reshape (b, shape (a), order = [3, 2, 1])
15  if (any (a(:, 2, 1) .ne. [zero, zero, one, zero, zero])) call abort
16  if (a(3, 2, 1) /= one) call abort()
17  if (sum (abs (a)) /= one) call abort()
18end program
19