Created on 2024-12-27.00:00:00 last changed 1 month ago
(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].- ...
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-12-27 00:00:00 | admin | create |