[RFA 1/2] Make line tables independent of progspace

Simon Marchi simark@simark.ca
Wed Mar 28 12:30:00 GMT 2018


On 2018-03-28 12:53 AM, Tom Tromey wrote:
> Simon> Both branches return -1 here.
> 
> Ugh, sorry.  This got introduced during the changes to use member
> functions.
> 
> Simon> I don't mind the "left - right", I see that often.  Especially when you
> Simon> want to sort by multiple fields, it's short and clear (IMO) to do
> 
> In this particular case I think it is a bit weird, because the addresses
> are unsigned, so this is relying on the implicit cast to make the value
> negative.  But also, because the addresses are CORE_ADDR and the return
> type is int, it seems like underflow is possible as well (in theory, I
> suppose I wouldn't expect it in practice).
> 
> So, I thought rather than being tricky here, it was more obviously
> correct to just write the longer form.  Which would be true if it didn't
> introduce bugs.

Ah, I thought that subtracting two unsigned yielded a signed result, like
subtracting two pointers gives a ptrdiff_t result (which is signed).  But
that doesn't seem true.  So I'm fine with changing it then.



More information about the Gdb-patches mailing list