[Bug fortran/61767] [OOP] ICE in generate_finalization_wrapper at fortran/class.c:1491
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 8 12:48:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61767
--- Comment #10 from janus at gcc dot gnu.org ---
(In reply to janus from comment #9)
> Thus: The patch in comment #7 should be discarded, and comment #5 is the way
> to go here.
I just realized that also comment #5 is not fully correct. Instead the problem
originates from a different place: The function 'has_finalizer_component' is
buggy and can be fixed like this ...
Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c (revision 243433)
+++ gcc/fortran/class.c (working copy)
@@ -841,20 +841,19 @@ has_finalizer_component (gfc_symbol *derived)
gfc_component *c;
for (c = derived->components; c; c = c->next)
- {
- if (c->ts.type == BT_DERIVED && c->ts.u.derived->f2k_derived
- && c->ts.u.derived->f2k_derived->finalizers)
- return true;
+ if (c->ts.type == BT_DERIVED && !c->attr.pointer && !c->attr.allocatable)
+ {
+ if (c->ts.u.derived->f2k_derived
+ && c->ts.u.derived->f2k_derived->finalizers)
+ return true;
- /* Stop infinite recursion through this function by inhibiting
- calls when the derived type and that of the component are
- the same. */
- if (c->ts.type == BT_DERIVED
- && !gfc_compare_derived_types (derived, c->ts.u.derived)
- && !c->attr.pointer && !c->attr.allocatable
- && has_finalizer_component (c->ts.u.derived))
- return true;
- }
+ /* Stop infinite recursion through this function by inhibiting
+ calls when the derived type and that of the component are
+ the same. */
+ if (!gfc_compare_derived_types (derived, c->ts.u.derived)
+ && has_finalizer_component (c->ts.u.derived))
+ return true;
+ }
return false;
}
More information about the Gcc-bugs
mailing list