Title
Initialization of signed or unsigned char arrays from string-literal
Status
open
Section
9.5.1 [dcl.init.general]
Submitter
Jay Ghiron

Created on 2026-06-11.00:00:00 last changed 6 days ago

Messages

Date: 2026-07-01.21:37:11

Suggested resolution:

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

    The semantics of initializers are as follows. The destination type is the cv-unqualified type of the object or reference being initialized and the source type is the type of the initializer expression. If the initializer is not a single (possibly parenthesized) expression, the source type is not defined.
    • ...
    • If the destination type is an array of characters ordinary character type or of character type (6.9.2 [basic.fundamental]) , 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.5.3 [dcl.init.string].
    • ...
  2. Change in 9.5.5 [dcl.init.list] bullet 3.3 as follows:

    List-initialization of an object or reference of type cv T is defined as follows:
    • ...
    • Otherwise, if T is a character array an array of ordinary character type or of character type (6.9.2 [basic.fundamental]) and the initializer list has a single element that is an appropriately-typed string-literal (9.5.3 [dcl.init.string]), initialization is performed as described in that subclause.
    • ...
Date: 2026-06-11.00:00:00

(From submission #921.)

Subclause 9.5.3 [dcl.init.string] paragraph 1 clearly includes signed char and unsigned char in the list of array element types that can be initialized by a string-literal. However, 9.5.1 [dcl.init.general] bullet 16.3 does not.

History
Date User Action Args
2026-06-25 18:18:29adminsetmessages: + msg8610
2026-06-11 00:00:00admincreate