[Bug fortran/106121] ICE in gfc_simplify_extends_type_of, at fortran/simplify.cc:3109
sgk at troutmask dot apl.washington.edu
gcc-bugzilla@gcc.gnu.org
Tue Jun 28 20:02:25 GMT 2022
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.
More information about the Gcc-bugs
mailing list