aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/move_alloc_17.f90
blob: acede0f901bc72ace8dfc4c205e5b3313a660452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
! { dg-do compile }
!
! The call to MOVE_ALLOC below caused a seg fault in runtime.
! This was discussed in:
! https://groups.google.com/forum/#!topic/comp.lang.fortran/ZVLqXFYDZ0M
! Richard Maine proposed that the code violated the restrictions on
! actual arguments in F2003 12.4.1.7 and so the fix asserts that the
! TO and FROM arguments cannot be the same object or subobjects thereof.
!
!
program test_move_alloc
  type :: linked_list
     type(linked_list), allocatable :: link
     integer :: value
  end type linked_list
  type(linked_list) :: test

  allocate(test % link)
  allocate(test % link % link)
  call move_alloc(test % link, test % link % link) ! { dg-error "aliasing restrictions" }
end program test_move_alloc