From: Martin Liska Date: Tue, 29 Oct 2019 08:45:06 +0000 (+0100) Subject: Fix unsigned type overflow in memory report. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=50a2d3be7bf473c7590f77350fadf3471427ce09;p=gcc.git Fix unsigned type overflow in memory report. 2019-10-29 Martin Liska * ggc-common.c: One can't subtract unsigned types in compare function. From-SVN: r277560 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 51097bba544..b6eeeaddc8e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-10-29 Martin Liska + + * ggc-common.c: One can't subtract unsigned types + in compare function. + 2019-10-29 Martin Liska * cgraphunit.c (symbol_table::compile): Pass diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index 37d3c5df9e1..48db4208599 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -928,10 +928,13 @@ public: static int compare (const void *first, const void *second) { - const mem_pair_t f = *(const mem_pair_t *)first; - const mem_pair_t s = *(const mem_pair_t *)second; + const mem_pair_t mem1 = *(const mem_pair_t *) first; + const mem_pair_t mem2 = *(const mem_pair_t *) second; - return s.second->get_balance () - f.second->get_balance (); + size_t balance1 = mem1.second->get_balance (); + size_t balance2 = mem2.second->get_balance (); + + return balance1 == balance2 ? 0 : (balance1 < balance2 ? 1 : -1); } /* Dump header with NAME. */