This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/64739] New: Spurious "array subscript is above array bounds" warning


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

            Bug ID: 64739
           Summary: Spurious "array subscript is above array bounds"
                    warning
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: siddhesh at redhat dot com

Reduced Reproducer:

$ cat foo.c
void
foo (char **inptrp, char *inend, int *wch, int *cnt)
{ 
  int inlen = *cnt & 7;
  if (inlen != 0)
    { 
      char *inptr = *inptrp;
      char bytebuf[4];

      while (inptr < inend)
        bytebuf[inlen++] = *inptr++;

      *cnt = &bytebuf[inlen] - inptr;
      *wch = *inptr;
    }
}

$ gcc -O3 -Wall -o foo.s -S foo.c
foo.c: In function âfooâ:
foo.c:11:16: warning: array subscript is above array bounds [-Warray-bounds]
         bytebuf[inlen++] = *inptr++;
                ^

The warning disappears when one adds -fno-tree-vrp to the compile command.

The actual error appears when building the iconv bits in glibc.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]