On 05/03/2013 10:24 PM, Jason Merrill wrote:
Last year Florian fixed the compiler to detect overflow in array new
size calculations and pass (size_t)-1 in that case.  But C++11 specifies
that in case of overflow the program throws std::bad_array_new_length
(http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#624), so
I've adjusted the checking code accordingly.

Nice, this is simpler than expected. However, it makes the call sites even more bloated.

This patch also adds the type to libsupc++, and several exports to
libstdc++.

There's also overflow checking inside __cxa_vec_new[23]. At this point, we don't know if the caller was compiled in C++11 mode. But for C++03 code, throwing a subclass of std::bad_alloc probably won't hurt.

I noticed you use throw() in the declaration of std::bad_array_new_length and _GLIBCXX_USE_NOEXCEPT in the definition, which seems rather odd. I'm surprised that this even compiles.

--
Florian Weimer / Red Hat Product Security Team

Reply via email to