Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2642: Fixes for changes from LWG 2024/01/31 review #444

Open
mhoemmen opened this issue Feb 7, 2024 · 0 comments
Open

P2642: Fixes for changes from LWG 2024/01/31 review #444

mhoemmen opened this issue Feb 7, 2024 · 0 comments

Comments

@mhoemmen
Copy link
Contributor

mhoemmen commented Feb 7, 2024

Fixes for changes from LWG 2024/01/31

[mdspan.layout.leftpadded.cons]

The constexpr mapping(const extents_type& ext); constructor currently has the following precondition (paragraph 2.2).

  * [2.2]{.pnum} If `extents_type::rank()` is greater than one
    and `padding_value` does not equal `dynamic_extent`,
    then $\mathit{least\_multiple\_at\_least}($ `padding_value` $,$ `ext.extent(0)` $)$
    is representable as a value of type `index_type`.

Given this wording, the following is not a precondition violation but will still produce offsets exceeding MAX_INT.

constexpr int e1 = MAX_INT / 3;
constexpr int s1 = 2*e1;
layout_left_padded<s1>::mapping<dextents<int, 2>> map(dextents<int, 2>{e1, 2}); 

@crtrott suggests the following wording.

  * [2.2]{.pnum} If `extents_type::rank()` is greater than one
    and `padding_value` does not equal `dynamic_extent`,
    then $\mathit{least\_multiple\_at\_least}($ `padding_value` $,$ `ext.extent(0)` $)$
    times the size of the multidimensional index space `ext` divided by `ext.extent(0)`
    is representable as a value of type `index_type`.

Other

The Mandate "padding_value is representable as a value of type index_type" (without further qualifications) is wrong, because dynamic_extent is generally not representable as index_type.

index_type @_stride-rm2_@ = @_static-padding-stride_@ is an unsafe conversion when static-padding-stride is dynamic_extent and index_type is not size_t. The default member initializer shouldn't take effect in that case, but the syntax itself might still be incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant