https://gcc.gnu.org/ml/fortran/2016-08/msg00144.html On Wed, Aug 24, 2016 at 5:14 PM, Fritz Reese wrote: > With a few recent notes by others, I have identified that the > comparison logic I used in interface.c (compare_components, > gfc_compare_derived_types) was faulty in a few ways. (snip) > tl;dr: The attached patch fixes PR 77327 and another bug which is > demonstrated in the included testcase. Minor correction to a typo in the patch above - should be checking cmp1 and cmp2 not cmp1 and cmp1: diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index ffc36f5..f082464 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -425,7 +425,7 @@ compare_components (gfc_component *cmp1, gfc_component *cmp2 gfc_symbol *derived1, gfc_symbol *derived2) { /* Compare names, but not for anonymous components such as UNION or MAP. */ - if (!is_anonymous_component (cmp1) && !is_anonymous_component (cmp1) + if (!is_anonymous_component (cmp1) && !is_anonymous_component (cmp2) && strcmp (cmp1->name, cmp2->name) != 0) return 0; --- Fritz Reese 2016-08-24 Fritz Reese PR fortran/77327 gcc/fortran/ * interface.c (is_anonymous_component, is_anonymous_dt): New functions. * interface.c (compare_components, gfc_compare_derived_types): Use new functions. gcc/testsuite/gfortran.dg/ * dec_structure_13.f90: New testcase.