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

            Bug ID: 115996
           Summary: Missing  -Wanalyzer-infinite-loop with -Waddress
                    violation
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

```
int i;

int foo() {
        while(foo) {
                i++;
        }
}
```

```
$ gcc /tmp/p.c -fanalyzer -Wall -Wextra -c
/tmp/p.c: In function ‘foo’:
/tmp/p.c:4:15: warning: the address of ‘foo’ will always evaluate as ‘true’
[-Waddress]
    4 |         while(foo) {
      |               ^~~

$ gcc /tmp/p.c -fanalyzer -Wall -Wextra -O2 -c
/tmp/p.c: In function ‘foo’:
/tmp/p.c:4:15: warning: the address of ‘foo’ will always evaluate as ‘true’
[-Waddress]
    4 |         while(foo) {
      |               ^~~
```

I was expecting to see -Wanalyzer-infinite-loop reported.

I'm not sure if there's interest in the analyzer reporting things when there's
technically another warning for it. But this comes from a more sophisticated
example where the condition wasn't so obvious, so...

Reply via email to