This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3682. A Cpp17Allocator type can't silently ignore an unsupported alignment

Section: [allocator.requirements.general] Status: New Submitter: Jiang An Opened: 2022-03-18 Last modified: 2022-05-17

Priority: 3

View other active issues in [allocator.requirements.general].

View all other issues in [allocator.requirements.general].

View all issues with New status.


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.

[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."

Proposed resolution: