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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
Here's a slightly more reduced example that reproduces a similar warning:

$ cat pr92828.C && gcc -O2 -S -Wall pr92828.C
extern int f (void);

static const char*
g (unsigned n, const char *t)
{
  for (unsigned i = n; i--; )
    {
      if (f ())
        {
          const char *p = t + n;
          if (p[1] == '.' && p[2] == '.' && p[3] == '/')
            goto not_this_one;
          break;
        }

    not_this_one:;
    }

  return t;
}

void h (unsigned n)
{
  g (n, "-");
}
pr92828.C: In function ‘void h(unsigned int)’:
pr92828.C:11:26: warning: array subscript [2, 4294967297] is outside array
bounds of ‘const char [2]’ [-Warray-bounds]
   11 |    if (p[1] == '.' && p[2] == '.' && p[3] == '/')
      |                       ~~~^
pr92828.C:11:41: warning: array subscript [3, 4294967298] is outside array
bounds of ‘const char [2]’ [-Warray-bounds]
   11 |    if (p[1] == '.' && p[2] == '.' && p[3] == '/')
      |                                      ~~~^

Reply via email to