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

Created on 2019-02-20.00:00:00, last changed 2019-03-05.18:54:44.

Messages

Date: 2019-03-05.18:54:44

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-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
2019-03-05 18:54:44adminsetmessages: + msg10342
2019-03-03 18:40:22adminsetmessages: + msg10333
2019-02-20 00:00:00admincreate