Suppose I have the following in C++:
char buffer[SIZE];
char * ptr = &buffer[SIZE];
where ptr‘s value is never dereferenced. Is this even legal to do C++? That is use the memory address one stride from the last element of an array (say as a special value to compare to)?
If you said:
then yes, it is legal. You are specifically allowed by the C++ standard to use the one-past-the-end of an array in this manner, and it is used extensively when (for example) working with iterators.
Edit: But see comments by litb and Steve Jessop. If you want to be entirely politcally correct, you probably want:
Either way, the one-past-the-end address is a valid address – the perhaps not quite clear issue (as I understand it) is whether you are allowed to dereference it.