diff options
author | Luc Grosheintz <luc.grosheintz@gmail.com> | 2025-07-04 10:29:43 +0200 |
---|---|---|
committer | Tomasz Kamiński <tkaminsk@redhat.com> | 2025-07-08 13:43:47 +0200 |
commit | 4d86e4cda01aa3ab60de164a8492a99bc9ca1f70 (patch) | |
tree | 91ad7eed2d0bc0de5724403d2ea31a3f38d53b58 /gcc | |
parent | 90f7df6194e3c687000fcf725e18532838881d2f (diff) | |
download | gcc-4d86e4cda01aa3ab60de164a8492a99bc9ca1f70.zip gcc-4d86e4cda01aa3ab60de164a8492a99bc9ca1f70.tar.gz gcc-4d86e4cda01aa3ab60de164a8492a99bc9ca1f70.tar.bz2 |
libstdc++: Check prerequisites of layout_*::operator().
Previously, the prerequisite that the arguments passed to operator() are
a multi-dimensional index (of extents()) was not checked.
Both mapping::operator() and mdspan::operator[] have the same
prerequisite. Since, mdspan must check the prerequisite for user-defined
layout mappings, the preference is to check in mdspan.
Because out-of-bounds accesses are very common it's nevertheless useful
to check the prerequisite in mapping::operator(). This is relevant for
cases where the layout mappings are used without mdspan. This commit
checks the prerequisites via _GLIBCXX_DEBUG_ASSERTs and adds the required
tests.
More discussion in the email chain starting at:
https://gcc.gnu.org/pipermail/libstdc++/2025-July/062265.html
libstdc++-v3/ChangeLog:
* include/std/mdspan: Check prerequisites of
layout_*::operator() with _GLIBCXX_DEBUG_ASSERTs.
* testsuite/23_containers/mdspan/layouts/debug/out_of_bounds_neg.cc:
Add tests for prerequisites.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions