[Bug fortran/77351] ICE in remove_trim, at frontend-passes.c:1145

kargl at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Aug 23 18:44:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77351

--- Comment #2 from kargl at gcc dot gnu.org ---
Thou shalt not derefernce NULL pointers.

troutmask:sgk[238] svn diff frontend-passes.c 
Index: frontend-passes.c
===================================================================
--- frontend-passes.c   (revision 239661)
+++ frontend-passes.c   (working copy)
@@ -1137,6 +1137,8 @@ remove_trim (gfc_expr *rhs)
   bool ret;

   ret = false;
+  if (!rhs)
+    return ret;

   /* Check for a // b // trim(c).  Looping is probably not
      necessary because the parser usually generates
@@ -1274,6 +1276,9 @@ combine_array_constructor (gfc_expr *e)
   op1 = e->value.op.op1;
   op2 = e->value.op.op2;

+  if (!op1 || !op2)
+    return false;
+
   if (op1->expr_type == EXPR_ARRAY && op2->rank == 0)
     scalar_first = false;
   else if (op2->expr_type == EXPR_ARRAY && op1->rank == 0)


More information about the Gcc-bugs mailing list