[Bug c/70436] New: -Wmisleading-indentation missing warning

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 29 13:04:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70436

            Bug ID: 70436
           Summary: -Wmisleading-indentation missing warning
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

In PR70405 I've run into something we should IMNSHO definitely warn about:

void bar (int, int);

void
foo (int x, int y, int z)
{
  int i;
  if (x)
    for (i = 0; i < 64; i++)
      if (y)
        bar (1, i);
  else
    for (i = 0; i < 64; i++)
      if (z)
        bar (2, i);
}

but -W -Wall is quiet on this.  Here the else is indented as the code was meant
to work, but is actually parsed as
  if (x)
    for (i = 0; i < 64; i++)
      if (u)
        bar (1, i);
      else
        for (i = 0; i < 64; i++)
          if (z)
            bar (2, i);


More information about the Gcc-bugs mailing list