------- Comment #2 from jvdelisle at gcc dot gnu dot org  2007-05-15 03:38 
-------
I think the correct place to fix this is in trim.  The uninitialized variable
is being passed to the library from trim.  Looking at the fdump-tree-original,
you can see that the variable ch is initialized by setting to all blanks.  Then
a temporary char pointer is set up to pass to trim which is called with a
temporary len which is set by trim to zero when it scans through the string of
blanks.

This patch fixes this.

Index: string_intrinsics.c
===================================================================
*** string_intrinsics.c (revision 124646)
--- string_intrinsics.c (working copy)
*************** string_trim (GFC_INTEGER_4 * len, void *
*** 171,176 ****
--- 171,178 ----
        /* copy string if necessary.  */
        memmove (*dest, src, *len);
      }
+   else
+     *dest = NULL;
  }

With this patch, valgrind gives a clean report and it regression tested fine. 
I also checked the result of the same operation to a file.

I will commit this to trunk as simple and obvious if you agree.


-- 


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

Reply via email to