-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix LWG Issue 4060 (fix submdspan to prevent invalid pointer creation) (
#323) * Add failing test for Issue 4060 LWG Issue 4060 ("submdspan preconditions do not forbid creating invalid pointer") currently fails, because submdspan does not correctly handle the case where first_ of one or more slices is out of bounds. This commit adds two tests taken straight from the Issue. As expected, one test passes and the other test fails. However, both tests trigger undefined behavior for the layout mapping. * layout_right::operator(): Add debug-only bounds checking * Implement fix for LWG Issue 4060 * Make index bounds checking C++17 - friendly * Fix previous fix for only some slices at upper bound * Remove unnecessary tuple construction * Remove explicit use of fold expressions ... in favor of macros. In theory, this would help us backport submdspan to C++14. * Add bounds checking to layout_left & layout_stride * Add bounds checking to layout_left_padded & layout_right_padded * Remove no-longer-needed compiler feature tests * Fix Issue 4060 test; test layout_left & layout_stride too * Improve Issue 4060 test * Guard use of assert with _MDSPAN_DEBUG ...thus following the pattern of other uses of assert in the same header file. * Respond to review feedback * Add MDSPAN_INLINE_FUNCTION to bounds-checking functions * Pass indices by value to bounds-checking functions * Don't use std::forward for slices (use const ref instead) * Use required_span_size() in test * Replace bool_constant (since it's C++17) Co-authored-by: Damien L-G <[email protected]> --------- Co-authored-by: Damien L-G <[email protected]>
- Loading branch information
Showing
7 changed files
with
235 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Should this be
>=
instead?