http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53265



--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-03-12 
11:48:09 UTC ---

Second issue is from caller-save.c (setup_save_areas), again -Werror -O2:



int a, b[53][5], c[53][5];

int bar (void);



void

foo (void)

{

  int i, j, k;

  for (i = 0; i < 53; i++)

    for (j = 16 / (((a & 1) != 0) ? 8 : 4); j > 0; j--)

      {

        int d = 1;

        if (b[i][j] == 0 || c[i][1] != 0)

          continue;

        for (k = 0; k < j; k++)

          if (c[i + k][1])

            {

              d = 0;

              break;

            }

        if (!d)

          continue;

        c[i][j] = bar ();

      }

}



The problem I have in this testcase is that the undefined behavior isn't known

to happen unconditionally, b or c array content upon entry might very well

prevent it from happening.  So, if we want to warn for those, we'd need to have

two levels of the warning, one enabled perhaps by default, that hopefully

shouldn't have any false positives, and one with a different wording, enabled

perhaps by -Wall or even just -Wextra that would just say that iteration N may

trigger undefined behavior.  Haven't tried to find out if any target could have

problems there.

Reply via email to