Assuming that values of constant arrays never change, we can retrieve values for specific position(index) right from the initializer, if presented. Retrieve a character code by index from StringLiteral which is an initializer of constant arrays in global scope.
This patch has a known issue of getting access to characters past the end of the literal. The declaration, in which the literal is used, is an implicit cast of kind array-to-pointer. The offset should be in literal length's bounds. This should be distinguished from the states in the Standard C++20 (dcl.init.string) 9.4.2.3.
Example:
const char arr[42] = "123"; char c = arr[41]; // OK const char * const str = "123"; char c = str[41]; // NOK
I am wondering why this hunk is needed? getSValFromInitListExpr is handling this case at L1725, isn't it?