[Bug fortran/54243] [OOP] ICE (segfault) in gfc_type_compatible for invalid BT_CLASS

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 13 19:21:00 GMT 2012


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #2 from janus at gcc dot gnu.org 2012-08-13 19:21:15 UTC ---
I think the proper fix for both this one and PR 54244 would be the following:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c    (revision 190186)
+++ gcc/fortran/resolve.c    (working copy)
@@ -5793,6 +5795,9 @@ check_typebound_baseobject (gfc_expr* e)

   gcc_assert (base->ts.type == BT_DERIVED || base->ts.type == BT_CLASS);

+  if (base->ts.type == BT_CLASS && !gfc_expr_attr (base).class_ok)
+    return FAILURE;
+
   /* F08:C611.  */
   if (base->ts.type == BT_DERIVED && base->ts.u.derived->attr.abstract)
     {


This aborts the resolution of the type-bound call rather early (if the passed
object was not properly declared), avoiding all problems that one could
possibly run into later. It is also general enough that it should work for
other similar cases.



More information about the Gcc-bugs mailing list