Possible Duplicate:
Can a string literal be subscripted in a constant expression?
If I subscript a string literal, is the result a compile-time constant? In other words, is the following code valid?
constexpr char x = "a"[0];
GCC 4.7 says it is, but what does the standard have to say on this matter?
For the curious: I can’t just write 'a', because the string literal is the result of the stringizing operator. Some compilers do have a charizing operator, but it’s only an extension.
I think you’re looking at 5.19 [expr.const]:
So the result of a string literal subscript operation may be converted to an rvalue in a core constant expression.
This is useful when defining constexpr operators for user-defined literals and user-defined string literals, although the variadic form can be more workable in some cases.