[Bug other/70968] New: Missed case for -Wmisleading-indentation

segher at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 5 22:58:00 GMT 2016


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

            Bug ID: 70968
           Summary: Missed case for -Wmisleading-indentation
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: segher at gcc dot gnu.org
  Target Milestone: ---

Compiling the following with current trunk:

===
void g(int);

void f1(int x)
{
        if (x) {
                g(x--);
        } while (x);
}

void f2(int x)
{
        if (x)
                g(x--);
        while (x);
}

void f3(int x)
{
        if (x) g(x--); while (x);
}
===

(-Wall -W -O2) only warns for f3.  f1 has quite misleading indentation.

A warning for "while (x);" wouldn't hurt either probably, if there is
no whitespace before the semicolon anyway, like in f3.


More information about the Gcc-bugs mailing list