[libcxx-commits] [PATCH] D110846: [libcxx] Make allocator<T>:allocate throw bad_array_new_length
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 1 10:28:16 PDT 2021
Quuxplusone added inline comments.
================
Comment at: libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp:68
assert(false);
- } catch (std::exception const&) {
+ } catch (std::bad_array_new_length const&) {
}
----------------
> The reason why I'm fine with this is that I expect few people will get broken by this. It's thrown on failure to allocate, which is a corner case (I mean, it's more of a corner case than something like out_of_range), and also I don't think a lot of people are expecting that you'd catch a failure to allocate with `std::length_error`.
Btw, notice that `bad_array_new_length` inherits from (and thus can-be-caught-as) `bad_alloc`, which is great. The fact that `length_error` //cannot// be caught as `bad_alloc` explains why, on the left side of this diff, we had to catch the least-common-ancestor class `exception`.
Also btw, @miyuki, how about fixing the comment on line 64 while you're here?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110846/new/
https://reviews.llvm.org/D110846
More information about the libcxx-commits
mailing list