Created on 2024-12-27.00:00:00 last changed 1 month ago
Additional notes (January 2025)
The resolution above does not allow this example:
S s = {"abc"};
This recurses back from 9.4.2 [dcl.init.aggr] bullet 4.3 to 9.4.1 [dcl.init.general].
Possible resolution:
Change in 9.4.1 [dcl.init.general] bullet 16.3 as follows:
- ...
- 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
initializerinitialization is fromaan unparenthesized string-literal, see 9.4.3 [dcl.init.string].- ...
(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 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 [SUPERSEDED]:
Change in 9.4.1 [dcl.init.general] bullet 16.3 as follows:
- ...
- 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 |
2025-02-02 20:48:58 | admin | set | messages: + msg7962 |
2025-02-02 20:48:58 | admin | set | status: open -> review |
2024-12-27 00:00:00 | admin | create |