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