[PATCH 1/6] tree-vrp: fix compare_assert_loc qsort comparator
Alexander Monakov
amonakov@ispras.ru
Sat Jul 15 20:49:00 GMT 2017
Subtracting values to produce a -/0/+ comparison value only works when
original values have limited range. Otherwise it leads to broken
comparator that indicates 0 < 0x40000000 < 0x80000000 < 0.
Yuri posted an equivalent patch just a few hours ago:
https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00882.html
* tree-vrp.c (compare_assert_loc): Properly compare hash values.
---
gcc/tree-vrp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 28205f1..d1888f6 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -6459,7 +6459,7 @@ compare_assert_loc (const void *pa, const void *pb)
return (a->e != NULL
? a->e->src->index - b->e->src->index
: a->bb->index - b->bb->index);
- return ha - hb;
+ return ha < hb ? -1 : 1;
}
/* Process all the insertions registered for every name N_i registered
--
1.8.3.1
More information about the Gcc-patches
mailing list