-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
When a std::span is constructed such that it's nonempty (not default constructed or zero-length), then data() + size() is a valid pointer to materialize and work with as the pointer past the end of the putative array being referenced. Under #if __has_feature(undefined_behavior), merely computing data() + size() will insert checks that the pointer doesn't become invalid due to overflow or alignment or so on. It would be useful if std::span constructors, when compiled with ubsan checking, did something like std::ignore = data() + size(); at the end of the constructor so these checks will be triggered as soon as the initial UB (invalid pointer/size combination passed to span constructors) is perpetrated, not only when some later span method (or caller code) triggers the check by materializing some pointer relative to data().
CC: @PiJoules