This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix unstable sort, PR28964
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 25 Sep 2006 10:04:19 -0400 (EDT)
- Subject: Re: [PATCH] Fix unstable sort, PR28964
- References: <Pine.LNX.4.64.0609221319370.31619@nyjnma.fhfr.qr>
On Fri, 22 Sep 2006, Richard Guenther wrote:
> * cfgexpand.c (stack_var_size_cmp): Use DECL_UID to make
> sort of stack variables stable.
> + /* For stack variables of the same size use the uid of the decl
> + to make the sort stable. */
> + if (uida < uidb)
> + return -1;
> + if (uida > uidb)
> + return 1;
> + gcc_unreachable ();
I've read the follow-up conversation, but it just seemed a
coincidence that this worked for you; that you were using a
qsort implementation that avoids comparing an element by itself;
there's no such promise. Maybe for future situations (the
current one being moot perhaps) something like this instead of
the gcc_unreachable?
/* Must be the same element, then. */
gcc_assert (a == b);
> return 0;
> }
brgds, H-P