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

            Bug ID: 122975
           Summary: [13/14/15/16 Regression] -Wanalyzer-infinite-recursion
                    false positive involving integer values
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: fabio.porcedda at gmail dot com
  Target Milestone: ---

Created attachment 62977
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62977&action=edit
test.c to reproduce the regression

-Wanalyzer-infinite-loop reports a false positive in test.c

Tested on gcc 13.4, 14.3, 15.2 and 16.0

$ gcc -fanalyzer -c test.c 
test.c: In function ‘fun’:
test.c:4:9: warning: infinite recursion [CWE-674]
[-Wanalyzer-infinite-recursion]
    4 |         fun(x, -x);
      |         ^~~~~~~~~~
  ‘fun’: events 1-4
    │
    │    1 | void fun(int x, int y)
    │      |      ^~~
    │      |      |
    │      |      (1) entry to ‘fun’
    │    2 | {
    │    3 |     if (x + y != 0)
    │      |        ~
    │      |        |
    │      |        (2) following ‘true’ branch... ─>─┐
    │      |                                          │
    │      |                                          │
    │      |┌─────────────────────────────────────────┘
    │    4 |│        fun(x, -x);
    │      |│        ~~~~~~~~~~
    │      |│        |
    │      |└───────>(3) ...to here
    │      |         (4) calling ‘fun’ from ‘fun’
    │
    └──> ‘fun’: events 5-8
           │
           │    1 | void fun(int x, int y)
           │      |      ^~~
           │      |      |
           │      |      (5) initial entry to ‘fun’
           │    2 | {
           │    3 |     if (x + y != 0)
           │      |        ~
           │      |        |
           │      |        (6) following ‘true’ branch... ─>─┐
           │      |                                          │
           │      |                                          │
           │      |┌─────────────────────────────────────────┘
           │    4 |│        fun(x, -x);
           │      |│        ~~~~~~~~~~
           │      |│        |
           │      |└───────>(7) ...to here
           │      |         (8) calling ‘fun’ from ‘fun’
           │
           └──> ‘fun’: events 9-10
                  │
                  │    1 | void fun(int x, int y)
                  │      |      ^~~
                  │      |      |
                  │      |      (9) recursive entry to ‘fun’; previously
entered at (5)
                  │      |      (10) ⚠️  apparently infinite recursion
                  │

Reply via email to