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

            Bug ID: 114914
           Summary: False positive with -Wanalyzer-out-of-bounds
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: udo at hypervisor dot org
  Target Milestone: ---

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

For the attached test case, the analyzer incorrectly flags an array overflow as
follows: test.c:7:9: note: valid subscripts for ‘c’ are ‘[0]’ to ‘[1]’

The analyzer doesn't grok that v is in range 253...254 in the else-branch of
x() and therefore n is in range 0...1 when f() is called.

Reproducer: https://godbolt.org/z/fnxxns13x

The false positive occurs with gcc-14.1.0-RC-20240430.
The latest release (gcc-13.2) sees nothing wrong with this code.
I would therefore consider this a regression.

Reply via email to