CppCoreGuidelines
CppCoreGuidelines copied to clipboard
Misleading statement about built-in array subscripts
ES.107 says:
Note The built-in array uses signed subscripts.
This is misleading. The built-in indexing operator can use either signed or unsigned subscripts.
The C++17 standard, section 8.2.1 [expr.sub] says:
A postfix expression followed by an expression in square brackets is a postfix expression. One of the expressions shall be a glvalue of type “array of T” or a prvalue of type “pointer to T” and the other shall be a prvalue of unscoped enumeration or integral type.
There's no suggestion in the standard that an index should be signed (or that it should be unsigned).