This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
std::layout_XX::mapping
misses preconditionSection: 23.7.3.4 [mdspan.layout] Status: C++23 Submitter: Christian Trott Opened: 2023-02-09 Last modified: 2023-11-22
Priority: Not Prioritized
View all issues with C++23 status.
Discussion:
As shortly discussed during the LWG review of a layout_stride
defect, there is currently no protection against
creating layout mappings with all static extents where the product of those extents exceeds the representable
value range of the index_type
.
layout_left::mapping<extents<int, 100000, 100000>> a{};
But a.required_span_size()
would overflow since the implied span size is 10B and thus exceeds what
int
can represent.
0
.
Hence we can check for this via a mandates check on the class.
The paper P2798R0 has been provided with the proposed wording as shown below.
[Issaquah 2023-02-10; LWG issue processing]
Move to Immediate for C++23
[2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Immediate → WP.]
Proposed resolution:
This wording is relative to N4928.
Modify 23.7.3.4.5.1 [mdspan.layout.left.overview] as indicated:
-2- If
-3-Extents
is not a specialization ofextents
, then the program is ill-formed.layout_left::mapping<E>
is a trivially copyable type that modelsregular
for eachE
. -?- Mandates: IfExtents::rank_dynamic() == 0
istrue
, then the size of the multidimensional index spaceExtents()
is representable as a value of typetypename Extents::index_type
.
Modify 23.7.3.4.6.1 [mdspan.layout.right.overview] as indicated:
-2- If
-3-Extents
is not a specialization ofextents
, then the program is ill-formed.layout_right::mapping<E>
is a trivially copyable type that modelsregular
for eachE
. -?- Mandates: IfExtents::rank_dynamic() == 0
istrue
, then the size of the multidimensional index spaceExtents()
is representable as a value of typetypename Extents::index_type
.
Modify 23.7.3.4.7.1 [mdspan.layout.stride.overview] as indicated:
-2- If
-3-Extents
is not a specialization ofextents
, then the program is ill-formed.layout_stride::mapping<E>
is a trivially copyable type that modelsregular
for eachE
. -?- Mandates: IfExtents::rank_dynamic() == 0
istrue
, then the size of the multidimensional index spaceExtents()
is representable as a value of typetypename Extents::index_type
.