Title
std::allocator::allocate sometimes returns too little storage
Status
c++20
Section
[allocator.members]
Submitter
Casey Carter

Created on 2019-02-20.00:00:00 last changed 45 months ago

Messages

Date: 2019-07-22.17:12:46

Proposed resolution:

This wording is relative to N4800.

  1. Change [allocator.members] as indicated:

    [[nodiscard]] T* allocate(size_t n);
    

    […]

    -4- Throws: bad_array_new_length if SIZE_MAX / sizeof(T) < n, or bad_alloc if the storage cannot be obtained.

Date: 2019-07-22.17:12:46

[ 2019 Cologne Wednesday night ]

Status to Ready; will open additional issue to reconcile this and 3038

Date: 2019-03-05.00:00:00

[ 2019-03-05 Priority set to 3 after reflector discussion ]

Date: 2019-02-20.00:00:00

[allocator.members]/2 says:

-2- Returns: A pointer to the initial element of an array of storage of size n * sizeof(T), aligned appropriately for objects of type T.

As in LWG 3038, we should not return too little storage for n objects of size sizeof(T), e.g. when n is SIZE_MAX / 2 and T is short.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2019-11-19 14:48:30adminsetstatus: voting -> wp
2019-10-07 02:48:00adminsetstatus: ready -> voting
2019-07-22 17:12:46adminsetmessages: + msg10493
2019-07-22 17:12:46adminsetstatus: new -> ready
2019-03-05 18:54:44adminsetmessages: + msg10342
2019-03-03 18:40:22adminsetmessages: + msg10333
2019-02-20 00:00:00admincreate