http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55133

             Bug #: 55133
           Summary: gcc-4.8-20121028 dubious array bound check
    Classification: Unclassified
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: nat...@t-online.de


Created attachment 28571
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28571
preprocessed file

Please double-check this array out of bound warning with gcc-4.8-20121028: 

./compiler/gcc-4.8.0-snap/bin/gcc c1.c -O3 -c -Wall

c1.c: In function ‘main’:
c1.c:15:22: warning: array subscript is above array bounds
[-Warray-bounds]
           if (!ab_pid[index])
                      ^

extern unsigned char ab_pid_count,old_rfcb_pid_count;
extern unsigned short ab_pid[16];
extern int found_pid;

int main()
{
  unsigned char pid_index = 0;
  int index;

  for (pid_index=0; (pid_index < old_rfcb_pid_count); pid_index++)
    {
      for (index=0; index < ab_pid_count; index++)
        {
          if (!ab_pid[index])
            {
              found_pid = 1;
            }
        };
    }

  return 0;
}

The warning disappear without the outer loop or with ' unsigned short
ab_pid[32]',

Reply via email to