re PR fortran/58058 (Memory leak with transfer function)

2013-08-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/58058
	* trans-intrinsic.c (gfc_conv_intrinsic_transfer): Free the temporary
	string, if necessary.

2013-08-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/58058
	* gfortran.dg/transfer_intrinsic_6.f90: New.

From-SVN: r201633
This commit is contained in:
Janus Weil 2013-08-09 18:57:58 +02:00
parent 042ae7d242
commit 36849c21cc
4 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2013-08-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/58058
* trans-intrinsic.c (gfc_conv_intrinsic_transfer): Free the temporary
string, if necessary.
2013-08-06 Martin Jambor <mjambor@suse.cz>
PR fortran/57987

View File

@ -5652,8 +5652,7 @@ scalar_transfer:
if (expr->ts.type == BT_CHARACTER)
{
tree direct;
tree indirect;
tree direct, indirect, free;
ptr = convert (gfc_get_pchar_type (expr->ts.kind), source);
tmpdecl = gfc_create_var (gfc_get_pchar_type (expr->ts.kind),
@ -5686,6 +5685,13 @@ scalar_transfer:
tmp = build3_v (COND_EXPR, tmp, direct, indirect);
gfc_add_expr_to_block (&se->pre, tmp);
/* Free the temporary string, if necessary. */
free = gfc_call_free (tmpdecl);
tmp = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
dest_word_len, source_bytes);
tmp = build3_v (COND_EXPR, tmp, free, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = tmpdecl;
se->string_length = fold_convert (gfc_charlen_type_node, dest_word_len);
}

View File

@ -1,3 +1,8 @@
2013-08-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/58058
* gfortran.dg/transfer_intrinsic_6.f90: New.
2013-08-09 Paolo Carlini <paolo.carlini@oracle.com>
Revert:

View File

@ -0,0 +1,20 @@
! { dg-do compile }
! { dg-options "-fdump-tree-original" }
!
! PR 58058: [4.7/4.8/4.9 Regression] Memory leak with transfer function
!
! Contributed by Thomas Jourdan <thomas.jourdan@orange.fr>
implicit none
integer, dimension(3) :: t1
character(len=64) :: str
t1 = (/1,2,3/)
str = transfer(t1,str)
end
! { dg-final { scan-tree-dump-times "__builtin_free" 1 "original" } }
! { dg-final { cleanup-tree-dump "original" } }