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

            Bug ID: 89053
           Summary: initializer-string too long for a large char array
                    initialized with empty string
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

While experimenting with the test case for pr89052 I came across the following
error issued by the G++ front-end for the string literal initializer.  Since
the equivalent brace-enclosed initializer is accepts the error looks like a bug
rather than a simple limitation.

$ cat a.c && gcc -S -Wall -xc++ a.c 
#include <limits.h>

char a[INT_MAX >> 2] = { '\0' };   // accepted
char b[INT_MAX >> 2] = "";         // error

a.c:4:24: error: initializer-string for array of chars is too long
[-fpermissive]
    4 | char b[INT_MAX >> 2] = "";         // error
      |                        ^~

Reply via email to