Consider the following simple code to sort an array.
int myarray[4] = {};
std::sort(myarray, myarray + 4);
I know that it is valid to create a pointer to one past the end of a C-style array.
I've recently seen code like this:
std::sort(myarray, &myarray[4]);
I'm not sure this is valid, because it dereferences an element outside the array bounds, even though the element value is not used for anything.
Is this valid code?