Skip to content

Behaviour of std::pmr::memory_resource::do_allocate() is ambiguous #966

Description

@iolojz

essentially a copy of this StackOverflow question.

To quote N4606:

virtual void* do_allocate(size_t bytes, size_t alignment) = 0;

Requires: Alignment shall be a power of two.

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; 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.

This is ambiguous: What happens if the alignment is a power of two but unsupported (e.g larger than max_align)? Is the returned storage aligned to max_align or is an exception thrown?

Metadata

Metadata

Assignees

Labels

lwgIssue must be reviewed by LWG.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions