https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117901
--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> --- I held off pushing because I had the scent of the problem. The "fix" of comment #3 was a dead giveaway. It turns out to be nothing to do with my fix for 102689 but is a latent bug exposed by the testcase. The fix, which regtests fine, is in trans-array.cc: @@ -8562,7 +8573,14 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) /* Set the dtype. */ tmp = gfc_conv_descriptor_dtype (parm); - if (se->unlimited_polymorphic) + if (UNLIMITED_POLY (expr) && GFC_ARRAY_TYPE_P (TREE_TYPE (desc))) + { + dtype = expr->symtree->n.sym->backend_decl; + dtype = GFC_DECL_SAVED_DESCRIPTOR (dtype); + dtype = gfc_class_data_get (dtype); + dtype = gfc_conv_descriptor_dtype (dtype); + } + else if (se->unlimited_polymorphic) dtype = gfc_get_dtype (TREE_TYPE (desc), &loop.dimen); else if (expr->ts.type == BT_ASSUMED) { I will now clean up the patch and produce a suitably reduced testcase that isolates the problem. Paul