This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/46244] gfc_compare_derived_types is buggy


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]