This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patcg, fortran] PR30200 write(*,myfmt="(1X,a,'xyz')") "A" prints Az' instead of Axyz


:ADDPATCH fortran:

The following simple patch fixes this problem by moving the freeing of memory holding the format string to after the transfer operations are complete. This clears up all the valgrind errors reported and gives clean output.

Regression tested on x86-64-linux. Test case attached.

I will commit under obvious and simple rule to trunk and then to 4.2 branch in a day.

Regards,

Jerry

2006-12-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR fortran/30200
	* trans-io.c (build_dt): Move post block for format_expr to end.


and the patch:


Index: trans-io.c
===================================================================
*** trans-io.c  (revision 119608)
--- trans-io.c  (working copy)
*************** build_dt (tree function, gfc_code * code
*** 1430,1436 ****
                            dt->advance);

        if (dt->format_expr)
!       mask |= set_string (&block, &post_block, var, IOPARM_dt_format,
                            dt->format_expr);

        if (dt->format_label)
--- 1430,1436 ----
                            dt->advance);

        if (dt->format_expr)
!       mask |= set_string (&block, &post_end_block, var, IOPARM_dt_format,
                            dt->format_expr);

if (dt->format_label)
! { dg-do run }
! PR30200 write(*,myfmt="(1X,a,'xyz')") "A"  prints  Az' instead of Axyz
! Test case from PR, submitted by <jvdelisle@gcc.gnu.org>
program main
  character (len=20) format
  format = "(1X,a,'xyz')"
  write(*,fmt=trim(format)) "A"  ! Problem arose when trim was included here
end
! { dg-output " Axyz" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]