https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89134
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dmalcolm at gcc dot gnu.org
--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
"inc" may be pure, but "do_something" isn't, so I don't see how it's valid to
optimize away the loop.
Consider e.g. this implementation in another TU:
int call_count;
int do_something(void)
{
call_count++;
return 1;
}
...or somesuch.
(also "b" is global, so presumably there could be another thread touching it,
or observing the changes made by the loop)