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

            Bug ID: 61957
           Summary: Wrong -Warray-bounds warning depending on parameter
                    types
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tavianator at gmail dot com

Created attachment 33205
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33205&action=edit
Test case

On x86-64 Linux, the attached testcase produces the duplicate spurious warning
with -O3 and -Wall:

$ gcc -std=c11 -O3 -Wall -c array-bounds.c
array-bounds.c: In function 'cofactor':
array-bounds.c:9:10: warning: array subscript is above array bounds
[-Warray-bounds]
         n[k] = A[i][j];
          ^
array-bounds.c:9:10: warning: array subscript is above array bounds
[-Warray-bounds]

Interestingly, if the 'row' and 'col' parameters are changed to 'unsigned
long', the warning goes away.

Reply via email to