This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


1490. List-initialization from a string literal

Section: 9.4.5  [dcl.init.list]     Status: CD4     Submitter: Daveed Vandevoorde     Date: 2012-03-29

[Moved to DR at the November, 2014 meeting.]

Initialization of an array of characters from a string literal is handled by the third bullet of 9.4 [dcl.init] paragraph 16, branching off to 9.4.3 [dcl.init.string]. However, list initialization is handled by the first bullet, branching off to 9.4.5 [dcl.init.list], and there is no corresponding special case in 9.4.5 [dcl.init.list] paragraph 3 for an array of characters initialized by a brace-enclosed string literal. That is, an initialization like

  char s[4]{"abc"};

is ill-formed, which could be surprising. Similarly,

  std::initializer_list<char>{"abc"};

is plausible but also not permitted.

Notes from the October, 2012 meeting:

CWG agreed that the first example should be permitted, but not the second.

Proposed resolution (June, 2014):

This issue is resolved by the resolution of issue 1467.