Authors: Jay Ghiron
Date: 2026-06-03
Submitted against: C23
Status: Open
Cross-references: 1036
An array of character type can be initialized by a character string literal or UTF-8 string literal, optionally enclosed in braces. Successive bytes of the string literal (including the terminating null character if there is room or if the array is of unknown size) initialize the elements of the array.
An array with element type compatible with a qualified or unqualified
wchar_t,char16_t, orchar32_tcan be initialized by a wide string literal with the corresponding encoding prefix (L,u, orU, respectively), optionally enclosed in braces. Successive wide characters of the wide string literal (including the terminating null wide character if there is room or if the array is of unknown size) initialize the elements of the array.
(C23 6.7.11 "Initialization" paragraphs 15 and 16.)
The second quoted paragraph goes out of its way to mention qualified or unqualified types, so it is clear that:
#include<stddef.h>
const wchar_t x[]=L"";
_Atomic wchar_t y[]=L"";
Using const or volatile is valid when initializing with a
wchar_t string literal, but using _Atomic is not valid. The first
quoted paragraph says that the element type of an array type must be a
character type for it to be able to be initialized with a character
string literal or UTF-8 string literal.
The three types
char,signed char, andunsigned charare collectively called the character types.
(C23 6.2.5 "Types" paragraph 20.)
If this definition is to be used, then the following is not valid:
const char z[]="";
Though that clearly is not intended, otherwise it would be impossible
to define any function without __func__ being predefined in this
invalid way. Other parts of the standard use the phrasing "qualified
or unqualified character type" and "non-atomic character type" both to
refer to the same set of types, so "character type" on its own is
unclear.
const char a[]="";
Is this declaration valid?
_Atomic char b[]="";
Is this declaration valid? Only MSVC accepts this as being valid, but
MSVC also accepts the clearly invalid _Atomic wchar_t y[]=L"";.
#include<uchar.h>
const char16_t c[]=u"";
Is this declaration valid? That is, does "qualified or unqualified
wchar_t, char16_t, or char32_t" mean to include qualified
versions of char16_t and qualified versions of char32_t?
char d[]={"",};
Is this declaration valid? See also Issue 1036.
#include<uchar.h>
enum E:char16_t{e};
enum F:char32_t{f};
enum G:char8_t{g};
enum E h[]=u"";
enum F i[]=U"";
enum G j[]=u8"";
Is it intended that specifically the last declaration is invalid here? The wording clearly forbids it but perhaps this discrepancy was not intended.