https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107926

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note we reference char array still with:
unsigned short s[5] = {u"abc",1};
__WCHAR_TYPE__ s1[5] = {L"abc", 1};

But I also notice clang does too so maybe it is not so bad ...
Just for reference the C++ front-end does better (note I changed the types
since for C++, there are distant types):
<source>:1:26: error: too many initializers for 'char16_t [5]'
    1 | char16_t s[5] = {u"abc",1};
      |                          ^
<source>:2:27: error: too many initializers for 'wchar_t [5]'
    2 | wchar_t s1[5] = {L"abc", 1};
      |                           ^

And this is better error message than clang gives too:
<source>:1:21: error: excess elements in char array initializer
char s0[5] = {"abc",1};
                    ^
<source>:2:25: error: excess elements in char array initializer
char16_t s[5] = {u"abc",1};
                        ^
<source>:3:26: error: excess elements in char array initializer
wchar_t s1[5] = {L"abc", 1};
                         ^

I am thinking maybe I should copy the C++ front-end code ....

Reply via email to