From: Paul Thomas Date: Fri, 3 Nov 2017 19:17:19 +0000 (+0000) Subject: re PR fortran/81735 (double free or corruption (fasttop) error (SIGABRT) with charact... X-Git-Tag: releases/gcc-6.5.0~703 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=042e464099e4230198034617ffe03953727b5321;p=thirdparty%2Fgcc.git re PR fortran/81735 (double free or corruption (fasttop) error (SIGABRT) with character(:) and custom return type with allocatable) 2017-11-03 Paul Thomas PR fortran/81735 * trans-decl.c (gfc_trans_deferred_vars): Correct case where 'tmp' can be used unititialized. 2017-11-03 Paul Thomas PR fortran/81735 * gfortran.dg/pr81735.f90: New test. From-SVN: r254393 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8d75d55b2563..1e5211109595 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2017-11-03 Paul Thomas + + Backport from 7-branch + PR fortran/81735 + * trans-decl.c (gfc_trans_deferred_vars): Correct case where + 'tmp' can be used unititialized. + 2017-11-01 Andre Vehreschild Paul Thomas diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 272ac57dd58c..36f882029e21 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -4364,7 +4364,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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65728d749017..85087554b63d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-11-03 Paul Thomas + + Backport from 7-branch + PR fortran/81735 + * gfortran.dg/pr81735.f90: New test. + 2017-11-01 Paul Thomas Backport from trunk diff --git a/gcc/testsuite/gfortran.dg/pr81735.f90 b/gcc/testsuite/gfortran.dg/pr81735.f90 new file mode 100644 index 000000000000..6aae203aa0fa --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr81735.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! +! Contributed by Danila +! +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" } }