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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=86528

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
A reduced test case not involving loops is below.  There are a couple of places
in the constant_string() function where the handling of non-constant array
indices isn't correct and needs to be adjusted.  See also bug 86528.

static const char a[2][3] = { "1", "12" };
static const char b[2][2][5] = { { "1", "12" }, { "123", "1234" } };

int main ()
{
  {
    volatile int i = 1;
    int n = __builtin_strlen (a[i]);
    n += __builtin_strlen (a[0]);

    if (n != 3)
      __builtin_abort ();
  }

  {
     volatile int i = 1;
     int n = __builtin_strlen (b[1][i]);
     n += __builtin_strlen (b[1][0]);
     if (n != 7)
       __builtin_abort ();
  }
}

Reply via email to