------- Additional Comments From tobi at gcc dot gnu dot org  2005-05-11 20:45 
-------
This patch passes the testsuite and fixes the bug, but creates a memory leak:

       * decl.c (add_init_expr_to_sym): Create new gfc_charlen for each
       item with length = (*)

Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/decl.c,v
retrieving revision 1.35
diff -u -p -r1.35 decl.c
--- decl.c      29 Apr 2005 15:31:37 -0000      1.35
+++ decl.c      11 May 2005 20:39:13 -0000
@@ -740,6 +740,11 @@ add_init_expr_to_sym (const char *name,
          /* Update symbol character length according initializer.  */
          if (sym->ts.cl->length == NULL)
            {
+             /* If there are multiple CHARACTER variables declared on
+                the same line, we don't want them to share the same
+                length.  */
+             sym->ts.cl = gfc_get_charlen ();
+
              if (init->expr_type == EXPR_CONSTANT)
                sym->ts.cl->length =
                        gfc_int_expr (init->value.character.length);

In order to evade the memory leak, we should instead of setting
sym->ts.cl->length = NULL, set sym->ts.cl = &gfc_unknown_charlen, where the
latter is a new global placeholder variable, and then fill in sym->ts.cl as I
did in the patch.  I've seen something like this in g95, but I don't remember if
this was what it was used for there.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21459

Reply via email to