[Bug fortran/29101] Memory leak in gfortran

pault at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Sep 18 06:53:00 GMT 2006

------- Comment #3 from pault at gcc dot gnu dot org  2006-09-18 06:53 -------
(In reply to comment #2)
> Problem is not in library side.

This is an easy one: Somebody forgot to add the post block for the evaluation
of the select expression to the block of code, for the specific case of
character expressions.


Index: gcc/fortran/trans-stmt.c
*** gcc/fortran/trans-stmt.c    (revision 117013)
--- gcc/fortran/trans-stmt.c    (working copy)
*************** gfc_trans_character_select (gfc_code *co
*** 1467,1472 ****
--- 1467,1474 ----
    tmp = build1 (GOTO_EXPR, void_type_node, tmp);
    gfc_add_expr_to_block (&block, tmp);

+   gfc_add_block_to_block (&block, &se.post);
    tmp = gfc_finish_block (&body);
    gfc_add_expr_to_block (&block, tmp);
    tmp = build1_v (LABEL_EXPR, end_label);

fixes it by producing the code:

    pstr.6 = (char[1:D.960] *) _gfortran_internal_malloc (D.960);
    tolower (pstr.6, D.960, D.958, D.959);
    goto _gfortran_select_string ((void *) &jumptable.5, 2, &L.5, pstr.6,
    _gfortran_internal_free ((void *) pstr.6);
    *value = 1;
    goto L.5;
    __result_validate_value = 0;
    goto L.5;

I am not going to be in a position to do anything about this for two weeks -
"I'm on the road again...". I can submit it today; if it is determined to be
essential to get into the 4.2 release, could you do the honors with the commit?

Are there any more such constructs in fortran that take a character expression?
 I could not immediately think of any.



pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
                 CC|                            |jvdelisle at gcc dot gnu dot
                   |                            |org


More information about the Gcc-bugs mailing list