https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107075
--- Comment #5 from anlauf at gcc dot gnu.org --- There is a check in expr.cc:2623 that is reached if one changes the testcase to a subroutine, but not if it is a program: 4615 if (!attr.save && rvalue->expr_type == EXPR_VARIABLE 4616 && rvalue->symtree->n.sym->ns->proc_name 4617 && rvalue->symtree->n.sym->ns->proc_name->attr.is_main_program) 4618 { 4619 rvalue->symtree->n.sym->ns->proc_name->attr.save = SAVE_IMPLICIT; 4620 attr.save = SAVE_IMPLICIT; 4621 } 4622 4623 if (!attr.save) 4624 { 4625 gfc_error ("Pointer initialization target at %L " 4626 "must have the SAVE attribute", &rvalue->where); 4627 return false; 4628 } I think the first check tries to fake that the target has the right attributes in a main program (implicit save) while it hasn't. If we fix the attributes of variables in the main program, the above check should be revisited.