The current wording in [dcl.init.string] p1 states:
An array of ordinary character type, [...] may be initialized by an ordinary string literal, [...], or by an appropriately-typed string-literal enclosed in braces.
Ordinary character type includes char
, signed char
, and unsigned char
(see [basic.fundamental]). It does not include the cv-qualified versions of those types.
From this, it isn't clear whether an array of const char
or volatile char
may also be initialized using a string literal, not just an array of char
. The wording is unclear because it doesn't say:
An array of cv ordinary character type, [...]
This matters in the following situation:
const char str[] = "test"; // is this valid?
I'm 99% sure that the intention is that you should be able to do it. However, is there a paragraph that definitively allows you to, or is this a wording defect?
char const[]
. What am I missing? – Folkmoot