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

            Bug ID: 68336
           Summary: False positive Wreturn-type warning
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yyc1992 at gmail dot com
  Target Milestone: ---

The following code gives a warning about control flow reaching the end of
function without returning a value even though the function will always reach
the `return 1;` statement and won't reach the end of the function.

```
int f()
{
    for (int i = 1;--i >= 0;) {
        return 1;
    }
}
```

Given no warning about this is given if the loop condition is replaced with `1`
I hope it is also possible for gcc to figure out that the loop is executed as
least once and silence the warning.

This (admittedly stupid....) code pattern arise from macro expansion to setup a
single time local context.

Reply via email to