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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
           Keywords|                            |ice-on-invalid-code
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
The ever popular NULL pointer dereference from
parsing invalid code.
With this patch

diff --git a/gcc/fortran/class.cc b/gcc/fortran/class.cc
index ae653e74437..9ece4482f76 100644
--- a/gcc/fortran/class.cc
+++ b/gcc/fortran/class.cc
@@ -2491,7 +2491,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
                  /* This is elemental so that arrays are automatically
                     treated correctly by the scalarizer.  */
                  copy->attr.elemental = 1;
-                 if (ns->proc_name->attr.flavor == FL_MODULE)
+                 if (ns->proc_name && ns->proc_name->attr.flavor == FL_MODULE)
                    copy->module = ns->proc_name->name;
                  gfc_set_sym_referenced (copy);
                  /* Set up formal arguments.  */
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 2ce0f3e4df7..54c9441d7fd 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -2499,7 +2499,7 @@ gfc_find_component (gfc_symbol *sym, const char *name,
   if (sym->attr.flavor == FL_DERIVED)
     sym = gfc_use_derived (sym);
   else
-    gcc_assert (gfc_fl_struct (sym->attr.flavor));
+    return NULL;

   if (sym == NULL)
     return NULL;

I get 
% gfcx -c a.f90
a.f90:13:34:

   13 |         character(len=this%f())::r  ! problem appears here
      |                                  1
Error: Symbol 'r' at (1) already has basic type of REAL
a.f90:13:22:

   13 |         character(len=this%f())::r  ! problem appears here
      |                      1
Error: Function 'this' at (1) must be PURE
a.f90:14:10:

   14 |         r='42'
      |          1
Error: Cannot convert CHARACTER(2) to REAL(4) at (1)
a.f90:19:9:

   19 |     use lib
      |         1
Fatal Error: Cannot open module file 'lib.mod' for reading at (1): No such file
or directory
compilation terminated.

The first and last errors appear to be run on errors.  The second error appears
to be the relevant one, but the 'name' of the function is munged.

Anywhoo, the patch fixes the ICE

Reply via email to