https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106121
--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Tue, Jun 28, 2022 at 07:43:39PM +0000, anlauf at gcc dot gnu.org wrote: > (In reply to kargl from comment #2) > > Infamous NULL pointer dereference. > > Yes. > > Shorter fix: > > diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc > index e8e3ec63669..b5112da441a 100644 > --- a/gcc/fortran/simplify.cc > +++ b/gcc/fortran/simplify.cc > @@ -3096,6 +3096,10 @@ gfc_simplify_extends_type_of (gfc_expr *a, gfc_expr > *mold) > if (UNLIMITED_POLY (a) || UNLIMITED_POLY (mold)) > return NULL; > > + if ((a->ts.type == BT_CLASS && !gfc_expr_attr (a).class_ok) > + || (mold->ts.type == BT_CLASS && !gfc_expr_attr (mold).class_ok)) > + return NULL; > + > /* Return .false. if the dynamic type can never be an extension. */ > if ((a->ts.type == BT_CLASS && mold->ts.type == BT_CLASS > && !gfc_type_is_extension_of > Shorter is definitely better. One thing that my patch allowed was shortening the tortured if-statement that is spread across a dozen of so lines. In any event, if you're patch survives regression testing, ok to commit.