Title
A Cpp17Allocator type can't silently ignore an unsupported alignment
Status
new
Section
[allocator.requirements.general]
Submitter
Jiang An

Created on 2022-03-18.00:00:00 last changed 1 week ago

Messages

Date: 2022-05-15.00:00:00

[ 2022-05-17; Reflector poll ]

Set priority to 3 after reflector poll.

"You can allocate from such an allocator but you can't construct objects in the allocated memory without manually checking the alignment of the returned pointer. That doesn't seem useful in practice."

"maybe even NAD/LEWG? I can't see us declaring most in-the-wild allocators to no longer be allocators. If anything, a design change is necessary to have a protocol for allocators to declare proper support for overalignment and for allocator_traits to implement such support "manually" for older allocators."

Date: 2022-03-18.00:00:00

Currently (at least since P0593R6), the allocate function of an allocator is required to create an array of elements ([allocator.requirements.general]), which means the allocated storage must be properly aligned (otherwise the array of requested size can't be created). However, according to paragraph 12 it is also allowed that "the allocator also may silently ignore the requested alignment".

IMO the allowance is contradictory and should be removed.

History
Date User Action Args
2022-05-17 11:58:16adminsetmessages: + msg12457
2022-03-18 00:00:00admincreate