kokkos / mdspan

Reference implementation of mdspan targeting C++23
Other
413 stars 69 forks source link

Fix LWG Issue 4060 (fix submdspan to prevent invalid pointer creation) #323

Closed mhoemmen closed 6 months ago

mhoemmen commented 7 months ago

Link to issue: https://cplusplus.github.io/LWG/issue4060

  1. Fix submdspan to prevent invalid pointer creation
  2. Implement bounds checking for the various layouts, so we can actually detect the issue

I aimed for C++14 backwards compatibility. Item (2) above is not strictly necessary to fix the issue, but it does help with finding the issue in the first place.

Bounds checking is only enabled in a debug build (if NDEBUG is not defined). It involves some fold expressions over assert expressions. I'm not attached to the use of assert for reporting errors.