https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123973
Bug ID: 123973
Summary: [13/14/15/16 Regression] -Wanalyzer-infinite-recursion
false positive involving integer expression
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 63587
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63587&action=edit
Code 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:6:9: warning: infinite recursion [CWE-674]
[-Wanalyzer-infinite-recursion]
6 | fun(x, Z - x);
| ^~~~~~~~~~~~~
‘fun’: events 1-4
│
│ 3 | void fun(int x, int y)
│ | ^~~
│ | |
│ | (1) entry to ‘fun’
│ 4 | {
│ 5 | if (x + y > Z)
│ | ~
│ | |
│ | (2) following ‘true’ branch... ─>─┐
│ | │
│ | │
│ |┌─────────────────────────────────────────┘
│ 6 |│ fun(x, Z - x);
│ |│ ~~~~~~~~~~~~~
│ |│ |
│ |└───────>(3) ...to here
│ | (4) calling ‘fun’ from ‘fun’
│
└──> ‘fun’: events 5-8
│
│ 3 | void fun(int x, int y)
│ | ^~~
│ | |
│ | (5) initial entry to ‘fun’
│ 4 | {
│ 5 | if (x + y > Z)
│ | ~
│ | |
│ | (6) following ‘true’ branch... ─>─┐
│ | │
│ | │
│ |┌─────────────────────────────────────────┘
│ 6 |│ fun(x, Z - x);
│ |│ ~~~~~~~~~~~~~
│ |│ |
│ |└───────>(7) ...to here
│ | (8) calling ‘fun’ from ‘fun’
│
└──> ‘fun’: events 9-10
│
│ 3 | void fun(int x, int y)
│ | ^~~
│ | |
│ | (9) recursive entry to ‘fun’; previously
entered at (5)
│ | (10) ⚠️ apparently infinite recursion
│