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

            Bug ID: 125885
           Summary: False -Warray-bounds array subscript above array
                    bounds with lookup table
           Product: gcc
           Version: 16.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thadhouse1 at gmail dot com
  Target Milestone: ---

Created attachment 64777
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64777&action=edit
Minimal Reproduction of the issue in C, self contained

After upgrading to GCC 16, we noticed one of the functions we import from LLVM
to convert UTF8 to UTF 16 was failing to compile with an array subscript out of
bounds error. We boiled the bug down to the attached code, where it seems like
static analysis is ignoring the fact that a Lookup Table is being used, and is
just assuming an array read is out of bounds.

Attached is a minimal reproduction that reproduces the issue.

It seems to be that GCC is not actually flowing through the Lookup Table, and
is instead assuming it can return an index that is out of range.

Reply via email to