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

            Bug ID: 108768
           Summary: bogus -Warray-bounds warnings
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mi+gcc at aldan dot algebra.com
  Target Milestone: ---

Created attachment 54453
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54453&action=edit
Test case (otpcode.c after passing preprocessor)

Compiling the attached file (part of TCL-TRF package) with:

    gcc12 -O2 -Wall -Werror -c otpcode.i -o otpcode.o

You'll get:
In function 'extract',
    inlined from 'FlushDecoder' at otpcode.i:6170:21:
otpcode.i:6262:9: error: array subscript 9 is outside array bounds of 'char[9]'
[-Werror=array-bounds]
 6262 |   cc = s[start/8 +1];
      |        ~^~~~~~~~~~~~
otpcode.i: In function 'FlushDecoder':
otpcode.i:6131:8: note: at offset 9 into object 'b' of size 9
 6131 |   char b[9];
      |        ^
In function 'extract',
    inlined from 'FlushDecoder' at otpcode.i:6170:21:
otpcode.i:6263:9: error: array subscript 10 is outside array bounds of
'char[9]' [-Werror=array-bounds]
 6263 |   cr = s[start/8 +2];
      |        ~^~~~~~~~~~~~
otpcode.i: In function 'FlushDecoder':
otpcode.i:6131:8: note: at offset 10 into object 'b' of size 9
 6131 |   char b[9];
      |        ^


Note, how the "start/8 + 1" is being misread as "9"...
  • [Bug c/108768] New: bogus -Wa... mi+gcc at aldan dot algebra.com via Gcc-bugs

Reply via email to