re PR fortran/81735 (double free or corruption (fasttop) error (SIGABRT) with character(:) and custom return type with allocatable)

2017-11-03  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/81735
	* trans-decl.c (gfc_trans_deferred_vars): Correct case where
	'tmp' can be used unititialized.

2017-11-03  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/81735
	* gfortran.dg/pr81735.f90: New test.

From-SVN: r254389
This commit is contained in:
Paul Thomas 2017-11-03 19:01:29 +00:00
parent cebaca3600
commit 726e7a70b9
4 changed files with 40 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2017-11-03 Paul Thomas <pault@gcc.gnu.org>
PR fortran/81735
* trans-decl.c (gfc_trans_deferred_vars): Correct case where
'tmp' can be used unititialized.
2017-11-01 Paul Thomas <pault@gcc.gnu.org>
Backported from trunk

View File

@ -4499,7 +4499,10 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
&& sym->ts.u.cl->passed_length)
tmp = gfc_null_and_pass_deferred_len (sym, &init, &loc);
else
gfc_restore_backend_locus (&loc);
{
gfc_restore_backend_locus (&loc);
tmp = NULL_TREE;
}
/* Deallocate when leaving the scope. Nullifying is not
needed. */

View File

@ -1,3 +1,8 @@
2017-11-03 Paul Thomas <pault@gcc.gnu.org>
PR fortran/81735
* gfortran.dg/pr81735.f90: New test.
2017-11-01 Tamar Christina <tamar.christina@arm.com>
Backported from trunk

View File

@ -0,0 +1,25 @@
! { dg-do compile }
! { dg-options "-fdump-tree-original" }
!
! Contributed by Danila <flashmozzg@gmail.com>
!
program fooprog
implicit none
type FooType
integer, allocatable :: x
end type FooType
type(FooType), pointer :: bar
bar => foo()
contains
function foo() result(res)
type(FooType), pointer :: res
character(:), allocatable :: rt
rt = ""
res => null()
end function foo
end program fooprog
! { dg-final { scan-tree-dump-times "__builtin_free" 1 "original" } }