Skip to content

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

Closed

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?

Activity

  1. self-assigned this
    on Dec 13, 2016
  2. jensmaurer commented on Dec 13, 2016

    @jensmaurer
    Member

    I've asked for an LWG issue.

  3. added
    lwg
    on Dec 13, 2016
  4. jensmaurer commented on Dec 18, 2016

    @jensmaurer
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

lwg

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions