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

2025-03-08


2977. Initialization with string literals

Section: 9.4.1  [dcl.init.general]     Status: review     Submitter: Jiang An     Date: 2024-12-27

(From submission #661.)

Subclause 9.4.1 [dcl.init.general] bullet 16.3 specifies:

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:

Possible resolution [SUPERSEDED]:

Change in 9.4.1 [dcl.init.general] bullet 16.3 as follows:

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: