2017-06-16 Nathan Sidwell <nathan@acm.org>
+ * class.c (resort_type_method_vec): Avoid potential unsigned
+ overflow.
+
Don't defer noexcept_deferred_spec.
* cp-tree.h (unevaluated_noexcept_spec): Don't declare.
* decl.c (cxx_init_decl_processing): Initialize
gt_pointer_operator new_value,
void* cookie)
{
- vec<tree, va_gc> *method_vec = (vec<tree, va_gc> *) obj;
- int len = vec_safe_length (method_vec);
- size_t slot;
- tree fn;
+ if (vec<tree, va_gc> *method_vec = (vec<tree, va_gc> *) obj)
+ {
+ int len = method_vec->length ();
+ int slot;
- /* The type conversion ops have to live at the front of the vec, so we
- can't sort them. */
- for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
- vec_safe_iterate (method_vec, slot, &fn);
- ++slot)
- if (!DECL_CONV_FN_P (OVL_FIRST (fn)))
- break;
+ /* The type conversion ops have to live at the front of the vec, so we
+ can't sort them. */
+ for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
+ slot < len; slot++)
+ if (!DECL_CONV_FN_P (OVL_FIRST ((*method_vec)[slot])))
+ break;
- if (len - slot > 1)
- {
- resort_data.new_value = new_value;
- resort_data.cookie = cookie;
- qsort (method_vec->address () + slot, len - slot, sizeof (tree),
- resort_method_name_cmp);
+ if (len > slot + 1)
+ {
+ resort_data.new_value = new_value;
+ resort_data.cookie = cookie;
+ qsort (method_vec->address () + slot, len - slot, sizeof (tree),
+ resort_method_name_cmp);
+ }
}
}