]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a68: fix comparison of pack element names in packs_ordering
authorJose E. Marchesi <jemarch@gnu.org>
Wed, 24 Jun 2026 21:57:38 +0000 (23:57 +0200)
committerJose E. Marchesi <jemarch@gnu.org>
Wed, 24 Jun 2026 21:59:09 +0000 (23:59 +0200)
Entry names of packs (struct fields, union alternatives, procedure
parameter list) cannot be compared purely by pointer value.  This
patch fixes the union alternative sorting code to not rely on this
false assumption.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* a68-moids-sorting.cc (packs_ordering): Do not rely on pointer
comparison when comparing pack element names.

gcc/algol68/a68-moids-sorting.cc

index 6579fbd2cc1e491141f2ad886d06ae945ba244dc..53c3487fb28163b2852cf5d9b21b11d379305680 100644 (file)
@@ -52,7 +52,10 @@ packs_ordering (PACK_T *a, PACK_T *b, bool compare_names = true)
                return 1;
              if (TEXT (b) == NO_TEXT)
                return -1;
-             return -strcmp (TEXT (a), TEXT (b));
+
+             int cmp = strcmp (TEXT (a), TEXT (b));
+             if (cmp != 0)
+               return -cmp;
            }
        }
     }