This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFC: fix bug in compare_breakpoints
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 18 Oct 2012 09:52:50 +0100
- Subject: Re: RFC: fix bug in compare_breakpoints
- References: <87sj9c28o1.fsf@fleche.redhat.com>
On 10/17/2012 08:35 PM, Tom Tromey wrote:
> I built gdb with clang today.
>
> This found a bunch of nits (I'll send a nit-cleanup patch later) but
> also a couple real bugs.
>
> Here's the first one. compare_breakpoints has an invalid comparison.
>
> Built (with clang and gcc) and regtested (gcc only) on x86-64 F16.
Eh! Shame that gcc doesn't warn on this ("comparison always false",
I gather?). Sounds like something that shouldn't be hard for the
compiler to detect. IWBN to have gcc PRs for these issues.
>
> Tom
>
> 2012-10-17 Tom Tromey <tromey@redhat.com>
>
> * breakpoint.c (compare_breakpoints): Fix comparison.
>
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index bebad75..76e3e89 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -11766,7 +11766,7 @@ compare_breakpoints (const void *a, const void *b)
> the number 0. */
> if (ua < ub)
> return -1;
> - return ub > ub ? 1 : 0;
> + return ua > ub ? 1 : 0;
> }
>
> /* Delete breakpoints by address or line. */
>
--
Pedro Alves