[gcc r16-9353] a68: fix comparison of pack element names in packs_ordering
"Jose E. Marchesi via Gcc-cvs" <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:b1a7a72d8c2aab445ab14ef116e982a14e87ab3a commit r16-9353-gb1a7a72d8c2aab445ab14ef116e982a14e87ab3a Author: Jose E. Marchesi <[email protected]> Date: Wed Jun 24 23:57:38 2026 +0200 a68: fix comparison of pack element names in packs_ordering 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 <[email protected]> gcc/algol68/ChangeLog * a68-moids-sorting.cc (packs_ordering): Do not rely on pointer comparison when comparing pack element names. (cherry picked from commit 3ed55c5ee90e0cdb2e2edc7aa4976f5cea7bd5ec) Diff: --- gcc/algol68/a68-moids-sorting.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/algol68/a68-moids-sorting.cc b/gcc/algol68/a68-moids-sorting.cc index 6579fbd2cc1e..53c3487fb281 100644 --- a/gcc/algol68/a68-moids-sorting.cc +++ b/gcc/algol68/a68-moids-sorting.cc @@ -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; } } }