[Bug c/70954] New: -Wmisleading-indentation false positive on GNU "ed"

dmalcolm at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 4 17:32:00 GMT 2016


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

            Bug ID: 70954
           Summary: -Wmisleading-indentation false positive on GNU "ed"
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

A user reported a false positive with -Wmisleading-indentation when
compiling "ed" with gcc 6.1:
  https://gcc.gnu.org/ml/gcc/2016-05/msg00044.html

Minimal reproducer:

void test (const char ** const ibufpp)
{
  int c = *(*ibufpp)++;
  switch (c)
    {
    case '#': while( *(*ibufpp)++ != '\n' ) ;
              break;
    }
}

$ ./xgcc -B. -c test.c -Wall
test.c: In function ‘test’:
test.c:6:15: warning: this ‘while’ clause does not guard...
[-Wmisleading-indentation]
     case '#': while( *(*ibufpp)++ != '\n' ) ;
               ^~~~~
test.c:7:15: note: ...this statement, but the latter is misleadingly indented
as if it is guarded by the ‘while’
               break;
               ^~~~~

I agree that this is a false positive.

With trunk r235889 (and presumably the gcc-6-branch), we currently exit from
  should_warn_for_misleading_indentation
here:

495               /* Otherwise, they are visually aligned: issue a warning.  */
496               return true;


More information about the Gcc-bugs mailing list