On Mon, Dec 29, 2014 at 4:25 PM, Thomas Koenig <tkoe...@netcologne.de> wrote: > Hello world, > > this patch fixes the long-standing bug. A missing temporary > causes an invalid read in realloc_on_assign_5.f03 which > only becomes noticable when setting MALLOC_CHECK_ or when > using valgrind. The bug has three duplicates in the > data base, so people keep stumbling across this. > > I have to confess I could not find the right way to put > this into the normal dependency code; the assumption that > the string copying will "do the right thing" is too deeply > embedded in the code, or I have been looking at the wrong places. > > So I took the approach of using the big hammer of a frontend > pass to fix this up. > > I would definitely like to see this bug fixed for 5.0. If anybody > has a better idea on how to tackle this in a timely manner, please > let me know. > > Otherwise, OK for trunk? What about the other branches? > > Regression-tested. > > 2014-12-29 Thomas Koenig <tkoe...@gcc.gnu.org> > > PR fortran/47674 > * dependency.c (gfc_discard_nops): Add prototype. > * dependency.c (discard_nops): Rename to gfc_discard_nops, > make non-static. > (gfc_discard_nops): Use gfc_discard_nops. > (gfc_dep_difference): Likewise. > * frontend-passes.c (realloc_strings): New function. > Add prototype. > (gfc_run_passes): Call realloc_strings. > (realloc_string_callback): New function. > (create_var): Add prototype. Handle case of a > scalar character variable. > (optimize_trim): Do not handle allocatable variables. >
On Linux/x86, I got ../../src-trunk/gcc/fortran/frontend-passes.c: In function ‘int realloc_string_callback(gfc_code**, int*, void*)’: ../../src-trunk/gcc/fortran/frontend-passes.c:152:38: error: ‘gfc_discard_nops’ was not declared in this scope expr2 = gfc_discard_nops (co->expr2); ^ make[6]: *** [fortran/frontend-passes.o] Error 1 -- H.J.