[Bug analyzer/122975] [13/14/15 Regression] -Wanalyzer-infinite-recursion false positive involving integer values
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122975 --- Comment #6 from GCC Commits --- The releases/gcc-15 branch has been updated by David Malcolm : https://gcc.gnu.org/g:e869244a134c84ef9f5ba15d8005bf66f9f2048c commit r15-10673-ge869244a134c84ef9f5ba15d8005bf66f9f2048c Author: David Malcolm Date: Mon Dec 15 11:48:49 2025 -0500 analyzer: fold X + (-X) to zero [PR122975] gcc/analyzer/ChangeLog: PR analyzer/122975 * region-model-manager.cc (region_model_manager::maybe_fold_binop): Fold X + (-X) to zero. gcc/testsuite/ChangeLog: PR analyzer/122975 * c-c++-common/analyzer/arith-1.c: New test. * c-c++-common/analyzer/infinite-recursion-pr122975.c: New test. Signed-off-by: David Malcolm (cherry picked from commit c48970fc4a4d1747a50e6abd1634757212420c04)
[Bug analyzer/122975] [13/14/15 Regression] -Wanalyzer-infinite-recursion false positive involving integer values
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122975
--- Comment #5 from Fabio Porcedda ---
(In reply to David Malcolm from comment #3)
> Should be fixed on trunk for gcc 16 by the above patch.
>
> Keeping open to track backporting.
Hi David,
thanks for the fix.
I've tried the fix and i confirm that fixes the test.c but it is still present
with a slightly different code, please check test2.c
test2.c: In function ‘fun’:
test2.c:4:9: warning: infinite recursion [CWE-674]
[-Wanalyzer-infinite-recursion]
4 | fun(x, 8 - x);
| ^
‘fun’: events 1-4
│
│1 | void fun(int x, int y)
│ | ^~~
│ | |
│ | (1) entry to ‘fun’
│2 | {
│3 | if (x + y > 8)
│ |~
│ ||
│ |(2) following ‘true’ branch... ─>─┐
│ | │
│ | │
│ |┌─┘
│4 |│fun(x, 8 - 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 > 8)
│ |~
│ ||
│ |(6) following ‘true’ branch... ─>─┐
│ | │
│ | │
│ |┌─┘
│4 |│fun(x, 8 - 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
│
Could you please fix this as well?
Thanks
[Bug analyzer/122975] [13/14/15 Regression] -Wanalyzer-infinite-recursion false positive involving integer values
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122975 --- Comment #4 from Fabio Porcedda --- Created attachment 63180 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63180&action=edit test2.c test to reproduce the issue even after test.c pass
[Bug analyzer/122975] [13/14/15 Regression] -Wanalyzer-infinite-recursion false positive involving integer values
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122975 David Malcolm changed: What|Removed |Added Summary|[13/14/15/16 Regression]|[13/14/15 Regression] |-Wanalyzer-infinite-recursi |-Wanalyzer-infinite-recursi |on false positive involving |on false positive involving |integer values |integer values --- Comment #3 from David Malcolm --- Should be fixed on trunk for gcc 16 by the above patch. Keeping open to track backporting.
