https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110519
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Optimize loop that only |Optimize for loop that only
|assigns to a local variable |assigns to a local variable
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2023-07-02
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. As mentioned the general rule does not apply for C, only applies to
`for` loops.
That is it would be invalid to remove the following loop in C:
```
struct symbol {
struct symbol *next;
};
void f(const struct symbol *sym)
{
const struct symbol *s = sym;
{
start_loop:
if (s != (void *)0)
{
do { } while (0);
s = s->next;
goto start_loop;
}
}
}
```