Closed reventlov closed 10 months ago
Keeping a pointer makes it very easy to make the pointer dangle, as in:
auto it = view.array().begin(); // it holds a pointer to the now-dead temporary `array()`
Further, since the equality checks in the iterator use the pointer, code like this walks off the end of the array:
assert(std::equal(view.array().begin(), view.array().end(), other.begin()));
Keeping a pointer makes it very easy to make the pointer dangle, as in:
Further, since the equality checks in the iterator use the pointer, code like this walks off the end of the array: