[all-commits] [llvm/llvm-project] be10b1: [libcxx] Make allocator<T>:allocate throw bad_arra...

Mikhail Maltsev via All-commits all-commits at lists.llvm.org
Mon Oct 18 11:13:44 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: be10b1f1cc5fc621c378da97810ffc13b2a9af71
      https://github.com/llvm/llvm-project/commit/be10b1f1cc5fc621c378da97810ffc13b2a9af71
  Author: Mikhail Maltsev <mikhail.maltsev at arm.com>
  Date:   2021-10-18 (Mon, 18 Oct 2021)

  Changed paths:
    M libcxx/docs/ReleaseNotes.rst
    M libcxx/docs/Status/Cxx20Issues.csv
    M libcxx/include/__memory/allocator.h
    M libcxx/include/experimental/memory_resource
    M libcxx/include/new
    M libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist
    M libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp
    M libcxx/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/do_allocate_and_deallocate.pass.cpp
    M libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp

  Log Message:
  -----------
  [libcxx] Make allocator<T>:allocate throw bad_array_new_length

Currently the member functions std::allocator<T>::allocate,
std::experimental::pmr::polymorphic_allocator::allocate and
std::resource_adaptor<T>::do_allocate throw an exception of type
std::length_error when the requested size exceeds the maximum size.

According to the C++ standard ([allocator.members]/4,
[mem.poly.allocator.mem]/1), std::allocator<T>::allocate and
std::pmr::polymorphic_allocator::allocate must throw a
std::bad_array_new_length exception in this case.

The patch fixes the issue with std::allocator<T>::allocate and changes
the type the exception thrown by
std::experimental::pmr::resource_adaptor<T>::do_allocate to
std::bad_array_new_length as well for consistency.

The patch resolves LWG 3237, LWG 3038 and LWG 3190.

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D110846




More information about the All-commits mailing list