https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103168
--- Comment #1 from Jan Hubicka <hubicka at gcc dot gnu.org> --- Sorry the testcase should have pure in it __attribute__((pure)) int test(); int main() { int ret; int a[10]; for (int i=0; i<10;i++) if (test()) a[i]++; for (int i=0; i<10;i++) ret *= a[i]; return ret; } with const things works as expected.