This is the mail archive of the gcc-bugs@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]

[Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c


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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

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

--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-31 04:56:02 UTC ---
This fixes it.

Index: gcc/fortran/frontend-passes.c
===================================================================
--- gcc/fortran/frontend-passes.c    (revision 171769)
+++ gcc/fortran/frontend-passes.c    (working copy)
@@ -334,6 +334,8 @@ cfe_code (gfc_code **c, int *walk_subtrees ATTRIBU
 static void
 optimize_namespace (gfc_namespace *ns)
 {
+  if (!ns->code)
+    return;

   current_ns = ns;

Regression tested.

trim_optimize_2.f90 fails but I do not know if this is because the patterns are
changed or this patch is just disabling the optimizations.

Also moving the check down a little bit still works, as follows.

Index: gcc/fortran/frontend-passes.c
===================================================================
--- gcc/fortran/frontend-passes.c    (revision 171769)
+++ gcc/fortran/frontend-passes.c    (working copy)
@@ -334,11 +334,14 @@ cfe_code (gfc_code **c, int *walk_subtrees ATTRIBU
 static void
 optimize_namespace (gfc_namespace *ns)
 {
-
   current_ns = ns;

   gfc_code_walker (&ns->code, cfe_code, cfe_expr_0, NULL);
+
   gfc_code_walker (&ns->code, optimize_code, optimize_expr, NULL);
+  
+  if (!ns->code)
+    return;

   for (ns = ns->contained; ns; ns = ns->sibling)
     optimize_namespace (ns);

I think somewhere while walking the code, the code pointer is getting bashed or
for this test case, it really is null.

Hope this at least gives some hints.


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