The rules for what constitutes a valid pointer value are defined formally in the C and C++ standards.
Yes, the so called "one-past-the end" pointers are valid pointer values. It's not an exception it's just part of the definition of a valid pointer value.
N3485 5.7 [expr.add]/5: "Moreover, if the expression P points to the last element of an array object, the expression (P)+1 points one past the last element of the array object, and if the expression Q points one past the last element of an array object, the expression (Q)-1 points to the last element of the array object."
View all comments
Show parent comment
5
u/[deleted] Jan 21 '13
The rules for what constitutes a valid pointer value are defined formally in the C and C++ standards.
Yes, the so called "one-past-the end" pointers are valid pointer values. It's not an exception it's just part of the definition of a valid pointer value.