This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/46244] gfc_compare_derived_types is buggy
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 30 Oct 2010 15:11:24 +0000
- Subject: [Bug fortran/46244] gfc_compare_derived_types is buggy
- Auto-submitted: auto-generated
- References: <bug-46244-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46244
--- Comment #4 from janus at gcc dot gnu.org 2010-10-30 15:11:19 UTC ---
(In reply to comment #3)
> The test case in comment #1 can be fixed by:
Or better:
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c (revision 166089)
+++ gcc/fortran/interface.c (working copy)
@@ -422,8 +422,11 @@ gfc_compare_derived_types (gfc_symbol *derived1, g
/* Since subtypes of SEQUENCE types must be SEQUENCE types as well, a
simple test can speed things up. Otherwise, lots of things have to
match. */
- for (;;)
+ while (dt1 || dt2)
{
+ if (dt1 == NULL || dt2 == NULL)
+ return 0;
+
if (strcmp (dt1->name, dt2->name) != 0)
return 0;
@@ -459,11 +462,6 @@ gfc_compare_derived_types (gfc_symbol *derived1, g
dt1 = dt1->next;
dt2 = dt2->next;
-
- if (dt1 == NULL && dt2 == NULL)
- break;
- if (dt1 == NULL || dt2 == NULL)
- return 0;
}
return 1;