[libcxx-dev] Why does std::allocator<T>::allocate throw std::length_error?
Mikhail Maltsev via libcxx-dev
libcxx-dev at lists.llvm.org
Tue Sep 28 06:21:10 PDT 2021
Hi,
I noticed that for some reason in libc++ the function
std::allocator<T>::allocate throws std::length_error when the allocation size
exceeds the maximum size, wheres the C++ standard [allocator.members] requires
to throw std::bad_alloc or std::bad_array_new_length depending on the version
of the standard.
AFAICT this deviation from the standard was introduced intentionally in the
following commit:
commit 4524d6e73953322eafee72aba62ddebef8f7c5cd
Author: Eric Fiselier <eric at efcs.ca>
Date: Sat May 7 03:12:24 2016 +0000
Change allocator<T>::allocate to throw length_error, not bad_alloc
llvm-svn: 268842
What is the rationale behind this change?
--
Regards,
Mikhail Maltsev
More information about the libcxx-dev
mailing list