https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78865
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The problem is that gfc_conv_procedure_call changes the type of the sub function from one returning void to one returning int: /* If there are alternate return labels, function type should be integer. Can't modify the type in place though, since it can be shared with other functions. For dummy arguments, the typing is done to this result, even if it has to be repeated for each call. */ if (has_alternate_specifier && TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) != integer_type_node) { if (!sym->attr.dummy) { TREE_TYPE (sym->backend_decl) = build_function_type (integer_type_node, TYPE_ARG_TYPES (TREE_TYPE (sym->backend_decl))); se->expr = gfc_build_addr_expr (NULL_TREE, sym->backend_decl); } else TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) = integer_type_node; } While this can work for implicitly defined subroutine calls, if sym->backend_decl is actually merged with the subroutine definition, changing it afterwards just doesn't work. Either it should be diagnosed as bug earlier (noting that caller expects alternate return, but callee does not), or at least it shouldn't change the type of the function, but do something different (even just generate __builtin_trap instead of the call).