https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99101
--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
Of course since -ffinite-loops and the C++ standard require forward progress
here and all testcases expect the loop to not terminate we're in the realm of
undefined behavior. But I'm not yet convinced the control-dependence / CD-DCE
issue only shows up in such cases. That said, it's fully expected that
int xx;
int main()
{
int jobs_ = 1;
int at_eof_ = 0;
while (1)
{
for (int i = 0; i < jobs_; i++)
{
if (at_eof_)
continue;
at_eof_ = 1;
if (xx)
return 1;
}
jobs_ = 0;
}
return 0;
}
is eventually optimized to just return 1 with -ffinite-loops and we should
try to preserve that behavior.