diff options
Diffstat (limited to 'gcc/testsuite/gfortran.dg/move_alloc_17.f90')
-rw-r--r-- | gcc/testsuite/gfortran.dg/move_alloc_17.f90 | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/move_alloc_17.f90 b/gcc/testsuite/gfortran.dg/move_alloc_17.f90 new file mode 100644 index 00000000000..acede0f901b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/move_alloc_17.f90 @@ -0,0 +1,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 |