https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109686
Bug ID: 109686
Summary: Errorneous infinite loop detection
(-Winfinite-recursion)
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: madhur4127 at gmail dot com
Target Milestone: ---
This code:
```
#define myassert(x) \
do { \
if (! (x) ) \
abort(); \
} while (false)
static void recursive(int n) {
myassert(n > 0);
recursive(n - 1);
printf("%d\n", n);
}
```
should not result in infinite recursion. Assert fails for all non-positive
integers. For positive numbers it counts down to 0 and then fails.
This affect GCC12, GCC13 and trunk: https://compiler-explorer.com/z/57qrnzdEK