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

            Bug ID: 129006
           Summary: -Wanalyzer-out-of-bounds false positives on ITC
                    benchmark 199316-v1.0.0/src/underrun_st.c
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
            Blocks: 129005
  Target Milestone: ---

$ sarif-replay runs/20261124-152429-symbolic-itc/sarif/199316-v1.0.0.sarif 
In function 'underrun_st_004':
/home/dmalcolm/coding/2016-09-12-itc-benchmarks-unzipped/199316-v1.0.0/src/underrun_st.c:58:16:
warning: stack-based buffer over-read [-Wanalyzer-out-of-bounds]
   58 |         ret = *(p - 1); /*Tool should not detect this line as error*/
/*No ERROR:Data Underrun*/
      |                ^~~~~~~~~~~~~~
  'underrun_st_004': events 1-2
   54 |         int buf[5] = {1, 2, 3, 4, 5};
      |                    ^~~
      |                    |
      |                    (1) capacity: 20 bytes
......
   58 |         ret = *(p - 1); /*Tool should not detect this line as error*/
/*No ERROR:Data Underrun*/
      |                ~~~~~~~~~~~~~~
      |                |
      |                (2) out-of-bounds read from byte 18446744073709551616
till byte 18446744073709551619 but 'buf' ends at byte 20
/home/dmalcolm/coding/2016-09-12-itc-benchmarks-unzipped/199316-v1.0.0/src/underrun_st.c:58:16:
note: read of 4 bytes from after the end of 'buf'
   58 |         ret = *(p - 1); /*Tool should not detect this line as error*/
/*No ERROR:Data Underrun*/
      |                ^~~~~~~~~~~~~~
/home/dmalcolm/coding/2016-09-12-itc-benchmarks-unzipped/199316-v1.0.0/src/underrun_st.c:58:16:
note: valid subscripts for 'buf' are '[0]' to '[4]'
GNU C23: note: Diagram visualizing the predicted out-of-bounds access
In function 'underrun_st_004':
/home/dmalcolm/coding/2016-09-12-itc-benchmarks-unzipped/199316-v1.0.0/src/underrun_st.c:58:16:
warning: stack-based buffer over-read [-Wanalyzer-out-of-bounds]
  'underrun_st_main': events 1-2
    │
    │  205 | void underrun_st_main ()
    │      |      ^~~~~~~~~~~~~~~~
    │      |      |
    │      |      (1) entry to 'underrun_st_main'
    │......
    │  224 |                 underrun_st_004();
    │      |                               ~~~~             
    │      |                               |
    │      |                               (2) calling 'underrun_st_004' from
'underrun_st_main'
    │
    └──> 'underrun_st_004': events 3-5
           │
           │   52 | void underrun_st_004 ()
           │      |      ^~~~~~~~~~~~~~~
           │      |      |
           │      |      (3) entry to 'underrun_st_004'
           │   53 | {
           │   54 |         int buf[5] = {1, 2, 3, 4, 5};
           │      |                    ~~~
           │      |                    |
           │      |                    (4) capacity: 20 bytes
           │......
           │   58 |         ret = *(p - 1); /*Tool should not detect this line
as error*/ /*No ERROR:Data Underrun*/
           │      |                ~~~~~~~~~~~~~~
           │      |                |
           │      |                (5) out-of-bounds read from byte
18446744073709551616 till byte 18446744073709551619 but 'buf' ends at byte 20
           │
/home/dmalcolm/coding/2016-09-12-itc-benchmarks-unzipped/199316-v1.0.0/src/underrun_st.c:58:16:
note: read of 4 bytes from after the end of 'buf'
   58 |         ret = *(p - 1); /*Tool should not detect this line as error*/
/*No ERROR:Data Underrun*/
      |                ^~~~~~~~~~~~~~
/home/dmalcolm/coding/2016-09-12-itc-benchmarks-unzipped/199316-v1.0.0/src/underrun_st.c:58:16:
note: valid subscripts for 'buf' are '[0]' to '[4]'
GNU C23: note: Diagram visualizing the predicted out-of-bounds access


This seems to have regressed on trunk relative to GCC 16.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129005
[Bug 129005] GCC -fanalyzer improvements related to ITC benchmark

Reply via email to