[PATCH] Fix undefined behavior in ira-build.c
Jakub Jelinek
jakub@redhat.com
Fri Jun 27 07:16:00 GMT 2014
Hi!
This fixes the most common source of the new runtime diagnostics
during bootstrap-ubsan, if num is 0, ira_object_id_map is often
0 as well.
Ok for trunk/4.9?
2014-06-27 Jakub Jelinek <jakub@redhat.com>
* ira-build.c (sort_conflict_id_map): Don't call
qsort if num is 0, as ira_object_id_map might be NULL.
--- gcc/ira-build.c.jj 2014-05-30 10:51:16.000000000 +0200
+++ gcc/ira-build.c 2014-06-26 20:21:43.428987181 +0200
@@ -2821,8 +2821,9 @@ sort_conflict_id_map (void)
FOR_EACH_ALLOCNO_OBJECT (a, obj, oi)
ira_object_id_map[num++] = obj;
}
- qsort (ira_object_id_map, num, sizeof (ira_object_t),
- object_range_compare_func);
+ if (num)
+ qsort (ira_object_id_map, num, sizeof (ira_object_t),
+ object_range_compare_func);
for (i = 0; i < num; i++)
{
ira_object_t obj = ira_object_id_map[i];
Jakub
More information about the Gcc-patches
mailing list