This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.
std::align
requirements overly strictSection: 20.2.5 [ptr.align] Status: C++17 Submitter: Peter Dimov Opened: 2014-03-30 Last modified: 2017-07-30
Priority: 0
View all other issues in [ptr.align].
View all issues with C++17 status.
Discussion:
std::align
requires that its alignment
argument shall be "a fundamental alignment value or an
extended alignment value supported by the implementation in this context".
std::align
does not depend on the
requirement that alignment
be a fundamental or an extended alignment value; any power of two would be handled
the same way.
In addition, it is not possible for the user to even determine whether a value is "a fundamental alignment value
or an extended alignment value supported by the implementation in this context". One would expect values coming
from alignof
to be fine, but I'm not sure whether even that is guaranteed in the presence of alignas
.
Therefore, I propose that
Requires:
alignment
shall be a fundamental alignment value or an extended alignment value supported by the implementation in this context
be changed to
Requires:
alignment
shall be a power of two
[2014-06-16 Rapperswil]
Move to Ready
Proposed resolution:
This wording is relative to N3936.
Edit 20.2.5 [ptr.align] p2 as indicated:
void* align(std::size_t alignment, std::size_t size, void*& ptr, std::size_t& space);-1- […]
-2- Requires:
alignment
shall be afundamental alignment value or an extended alignment value supported by the implementation in this contextpower of two