https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107576
--- Comment #4 from anlauf at gcc dot gnu.org --- Partial fix: diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index b95c5cf2f96..f09fad337bc 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -6193,6 +6193,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, } else if (arg->expr->expr_type == EXPR_NULL && fsym && !fsym->attr.pointer + && fsym->attr.optional && (fsym->ts.type != BT_CLASS || !CLASS_DATA (fsym)->attr.class_pointer)) {