This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-30
(From submission #661.)
Subclause 9.4.1 [dcl.init.general] bullet 16.3 specifies:
- ...
- If the destination type is an array of characters, an array of char8_t, an array of char16_t, an array of char32_t, or an array of wchar_t, and the initializer is a string-literal, see 9.4.3 [dcl.init.string].
- ...
However, the initializer will be of the form = string-literal or (string-literal), neither of which is a string-literal, obviously.
On a slightly related note, implementations other than EDG and gcc in strict modes support parenthesized string literals, e.g.
const char s1[] = ("foo"); const char s2[] = {("foo")};
The latter is clearly not covered by 9.4.5 [dcl.init.list] bullet 3.3:
- ...
- Otherwise, if T is a character array and the initializer list has a single element that is an appropriately-typed string-literal (9.4.3 [dcl.init.string]), initialization is performed as described in that subclause.
- ...
Possible resolution:
Subclause 9.4.1 [dcl.init.general] bullet 16.3 specifies:
- ...
- If the destination type is an array of characters, an array of char8_t, an array of char16_t, an array of char32_t, or an array of wchar_t, and the
initializerinitializer isa string-literalof the form = string-literal or of the form ( string-literal ), see 9.4.3 [dcl.init.string].- ...