This is the mail archive of the gcc-patches@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]

Re: [PATCH] Fix unstable sort, PR28964


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


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