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

            Bug ID: 120166
           Summary: [15 Regression] constexpr array with 66 elements
                    yields "integer initializer is not an integer constant
                    expression"
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hp at gcc dot gnu.org
  Target Milestone: ---

Compiling the following code with plain gcc -c -std=c23 yields:
t.c:15:10: error: 'constexpr' integer initializer is not an integer constant
expression
   15 |      0,  1,  2,  3,  4,  5,  6,  7,

Note that the ok_array with one less element yields no error.  No error when
compiled as C++.

Works: r14-10114-g09680e3ee7d7 (native x86_64-linux; N.B.: needs explicit
-std=c23)
Also works: r16-456-g974b079741f9 (cris-elf)

Doesn't: r15-9238-g546f28f83ceba7 (aarch64-elf)
Doesn't: r16-48-gd508d24282c6 (aarch64-linux-gnu)
Also doesn't, according to my colleague, more importantly, the recent gcc-15
release for aarch64-linux-gnu.

So, this may be a case of a commit needing a backport to the gcc-15 branch.

constexpr unsigned char ok_array[] = {
     0,  1,  2,  3,  4,  5,  6,  7,
     8,  9, 10, 11, 12, 13, 14, 15,
    16, 17, 18, 19, 20, 21, 22, 23,
    24, 25, 26, 27, 28, 29, 30, 31,
    32, 33, 34, 35, 36, 37, 38, 39,
    40, 41, 42, 43, 44, 45, 46, 47,
    48, 49, 50, 51, 52, 53, 54, 55,
    56, 57, 58, 59, 60, 61, 62, 63,
    64,
};

constexpr unsigned char not_ok_array[] = {
     0,  1,  2,  3,  4,  5,  6,  7,
     8,  9, 10, 11, 12, 13, 14, 15,
    16, 17, 18, 19, 20, 21, 22, 23,
    24, 25, 26, 27, 28, 29, 30, 31,
    32, 33, 34, 35, 36, 37, 38, 39,
    40, 41, 42, 43, 44, 45, 46, 47,
    48, 49, 50, 51, 52, 53, 54, 55,
    56, 57, 58, 59, 60, 61, 62, 63,
    64, 65,
};

Reply via email to