https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100656
--- Comment #3 from anlauf at gcc dot gnu.org --- The following patch seems to fix the issue: diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 6d38ea78273..7eeef554c0f 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -4718,8 +4718,9 @@ done: /* For optional arguments, only check bounds if the argument is present. */ - if (expr->symtree->n.sym->attr.optional - || expr->symtree->n.sym->attr.not_always_present) + if ((expr->symtree->n.sym->attr.optional + || expr->symtree->n.sym->attr.not_always_present) + && expr->symtree->n.sym->attr.dummy) tmp = build3_v (COND_EXPR, gfc_conv_expr_present (expr->symtree->n.sym), tmp, build_empty_stmt (input_location)); If I understand the code correctly, the issue arises since we try to generate runtime checks for a compiler generated temporary that is not a dummy, thus hitting the assert in gfc_conv_expr_present.