https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103283
--- Comment #5 from anlauf at gcc dot gnu.org --- I did get some progress with the attempt: diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 87089321a3b..d5bbcd493b6 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1929,6 +1929,8 @@ simplify_const_ref (gfc_expr *p) /* Fall through. */ case AR_FULL: + if (p->ref->next == NULL) + return true; if (p->ref->next != NULL && (p->ts.type == BT_CHARACTER || gfc_bt_struct (p->ts.type))) { which fixes testcase z1.f90 as well as comment#3, but has a lot of regressions in the testsuite. But then I have to admit I do not understand that function well enough to fix it.