Title
Unclear behavior of std::pmr::memory_resource::do_allocate()
Status
c++20
Section
[mem.res.private]
Submitter
Jens Maurer

Created on 2016-12-13.00:00:00 last changed 38 months ago

Messages

Date: 2018-03-18.16:03:30

Proposed resolution:

Change the specification of do_allocate() ([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.

Date: 2018-03-17.00:00:00

[ 2018-3-17 Adopted in Jacksonville ]

Date: 2017-11-10.03:05:33

[ 2017-11 Albuquerque Wednesday issue processing ]

Move to Ready.

Date: 2017-02-12.00:00:00

[ 2017-02-12 Pablo responds and provides wording ]

The original intent was:

  • If the alignment is supported by the implementation (see below), then it must use that alignment or else throw.
  • If the alignment is not supported it must use max_align else throw.

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().

Date: 2017-01-27.00:00:00

[ 2017-01-27 Telecon ]

Priority 3; Marshall to ping Pablo for intent and provide wording.

Date: 2016-12-13.00:00:00

The specification of do_allocate() ([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.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-03-18 16:03:30adminsetmessages: + msg9726
2018-03-18 16:03:30adminsetstatus: voting -> wp
2018-02-12 01:13:49adminsetstatus: ready -> voting
2017-11-10 03:05:33adminsetmessages: + msg9535
2017-11-10 03:05:33adminsetstatus: new -> ready
2017-02-13 15:10:23adminsetmessages: + msg8938
2017-02-13 15:10:23adminsetmessages: + msg8937
2017-01-30 15:36:02adminsetmessages: + msg8819
2016-12-13 00:00:00admincreate