Commit c7f587bd by Paul Thomas

check.c (gfc_check_move_alloc): Introduce error to prevent aliasing between to and from arguments.

2016-11-05  Paul Thomas  <pault@gcc.gnu.org>

	* check.c (gfc_check_move_alloc): Introduce error to prevent
	aliasing between to and from arguments.

2016-11-05  Paul Thomas  <pault@gcc.gnu.org>

	* gfortran.dg/move_alloc_17.f03: New test.

From-SVN: r241872
parent 92657eb0
2016-11-05 Paul Thomas <pault@gcc.gnu.org>
* check.c (gfc_check_move_alloc): Introduce error to prevent
aliasing between to and from arguments.
2016-11-05 Janus Weil <janus@gcc.gnu.org>
Manuel Lopez-Ibanez <manu@gcc.gnu.org>
......
......@@ -3342,6 +3342,16 @@ gfc_check_move_alloc (gfc_expr *from, gfc_expr *to)
return false;
}
/* F2003 12.4.1.7 */
if (to->expr_type == EXPR_VARIABLE && from->expr_type ==EXPR_VARIABLE
&& !strcmp (to->symtree->n.sym->name, from->symtree->n.sym->name))
{
gfc_error ("The FROM and TO arguments at %L are either the same object "
"or subobjects thereof and so violate aliasing restrictions "
"(F2003 12.4.1.7)", &to->where);
return false;
}
/* CLASS arguments: Make sure the vtab of from is present. */
if (to->ts.type == BT_CLASS && !UNLIMITED_POLY (from))
gfc_find_vtab (&from->ts);
......
2016-11-05 Paul Thomas <pault@gcc.gnu.org>
* gfortran.dg/move_alloc_17.f03: New test.
2016-11-05 Richard Biener <rguenther@suse.de>
PR bootstrap/78188
......
! { 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment