<div dir="ltr">Hi Mikhail,<div><br></div><div>The following LWG issues are related. This seems to be a maze of twisty little DRs and I'm not surprised libc++ isn't fully up to date.</div><div><a href="https://cplusplus.github.io/LWG/issue3038">https://cplusplus.github.io/LWG/issue3038</a><br></div><div><a href="https://cplusplus.github.io/LWG/issue3190">https://cplusplus.github.io/LWG/issue3190</a></div><div><a href="https://cplusplus.github.io/LWG/issue3237">https://cplusplus.github.io/LWG/issue3237</a><br></div><div>It also would not surprise me if that commit from 2016 was due to a simple mixup of the common (but wrong in this case) "length_error" with the uncommon (but IIUC correct) "bad_array_new_length".</div><div>However, also notice that that commit comes right after a patch series implementing <experimental/memory_resource>, which <i>was</i> initially specified to throw `length_error` from polymorphic_allocator<T>. LWG3237 fixed it to throw `bad_array_new_length` instead.</div><div><br></div><div>Anyway, I'm sure a patch would be welcomed... and then held up for a while as Louis ponders the ABI-break implications. ;)</div><div><br></div>my $.02,<br class="gmail-Apple-interchange-newline"><div>–Arthur</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 28, 2021 at 9:21 AM Mikhail Maltsev via libcxx-dev <<a href="mailto:libcxx-dev@lists.llvm.org">libcxx-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I noticed that for some reason in libc++ the function<br>
std::allocator<T>::allocate throws std::length_error when the allocation size<br>
exceeds the maximum size, wheres the C++ standard [allocator.members] requires<br>
to throw std::bad_alloc or std::bad_­array_­new_­length depending on the version<br>
of the standard.<br>
<br>
AFAICT this deviation from the standard was introduced intentionally in the<br>
following commit:<br>
<br>
commit 4524d6e73953322eafee72aba62ddebef8f7c5cd<br>
Author: Eric Fiselier <<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>><br>
Date:   Sat May 7 03:12:24 2016 +0000<br>
<br>
    Change allocator<T>::allocate to throw length_error, not bad_alloc<br>
<br>
    llvm-svn: 268842<br>
<br>
What is the rationale behind this change?<br>
<br>
--<br>
Regards,<br>
  Mikhail Maltsev<br>
_______________________________________________<br>
libcxx-dev mailing list<br>
<a href="mailto:libcxx-dev@lists.llvm.org" target="_blank">libcxx-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev</a><br>
</blockquote></div>