| 1 |
! { dg-do run } |
| 2 |
! PR 25031 - We didn't cause an error when allocating an already |
| 3 |
! allocated array. |
| 4 |
! |
| 5 |
! This testcase has been modified to fix PR 49755. |
| 6 |
program alloc_test |
| 7 |
implicit none |
| 8 |
integer :: i |
| 9 |
integer, allocatable :: a(:) |
| 10 |
integer, pointer :: b(:) |
| 11 |
|
| 12 |
allocate(a(4)) |
| 13 |
! This should set the stat code but not change the size. |
| 14 |
allocate(a(3),stat=i) |
| 15 |
if (i == 0) STOP 1 |
| 16 |
if (.not. allocated(a)) STOP 2 |
| 17 |
if (size(a) /= 4) STOP 3 |
| 18 |
|
| 19 |
! It's OK to allocate pointers twice (even though this causes |
| 20 |
! a memory leak) |
| 21 |
allocate(b(4)) |
| 22 |
allocate(b(4)) |
| 23 |
end program |