https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99138
--- Comment #8 from anlauf at gcc dot gnu.org --- The check in interface.c:gfc_check_result_characteristics has an asymmetry coming from symbol.c:gfc_type_compatible that could be evaded by swapping arguments: diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index f7ca52e6550..8758f146d57 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1561,7 +1561,7 @@ gfc_check_result_characteristics (gfc_symbol *s1, gfc_symbol *s2, return true; /* Check type and rank. */ - if (!compare_type_characteristics (r1, r2)) + if (!compare_type_characteristics (r2, r1)) { snprintf (errmsg, err_len, "Type mismatch in function result (%s/%s)", gfc_typename (&r1->ts), gfc_typename (&r2->ts)); However, we then hits other issues later on with the ALLOCATABLE attribute. :-(