This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
Section: 20.4.2.3 [mem.res.private] Status: C++20 Submitter: Jens Maurer Opened: 2016-12-13 Last modified: 2021-02-25
Priority: 3
View all other issues in [mem.res.private].
View all issues with C++20 status.
Discussion:
The specification of do_allocate() (20.4.2.3 [mem.res.private] p2+p3) says:
Returns: A derived class shall implement this function to return a pointer to allocated storage (3.7.4.2) with a size of at least bytes. The returned storage is aligned to the specified alignment, if such alignment is supported (3.11); otherwise it is aligned to max_align.
Throws: A derived class implementation shall throw an appropriate exception if it is unable to allocate memory with the requested size and alignment.
It is unclear whether a request for an unsupported alignment (e.g. larger than max_align) yields an exception or the returned storage is silently aligned to max_align.
This is editorial issue #966.[2017-01-27 Telecon]
Priority 3; Marshall to ping Pablo for intent and provide wording.
[2017-02-12 Pablo responds and provides wording]
The original intent was:
However, the description of do_allocate might have gone stale as the aligned-allocation proposal made its way into the standard.
The understanding I take from the definition of extended alignment in (the current text of) 3.11/3 [basic.align] and "assembling an argument list" in 5.3.4/14 [expr.new] is that it is intended that, when allocating space for an object with extended alignment in a well-formed program, the alignment will be honored and will not be truncated to max_align. I think this is a change from earlier drafts of the extended-alignment proposal, where silent truncation to max_align was permitted (I could be wrong). Anyway, it seems wrong to ever ignore the alignment parameter in do_allocate().
[2017-11 Albuquerque Wednesday issue processing]
Move to Ready.
[2018-3-17 Adopted in Jacksonville]
Proposed resolution:
Change the specification of do_allocate() (20.4.2.3 [mem.res.private] p2+p3) as follows:
Returns: A derived class shall implement this function to return a pointer to allocated storage (3.7.4.2) with a size of at least bytes, aligned to the specified alignment.
The returned storage is aligned to the specified alignment, if such alignment is supported; otherwise it is aligned to max_align.Throws: A derived class implementation shall throw an appropriate exception if it is unable to allocate memory with the requested size and alignment.