Since I'm unable to create an account to report a bug and got no reply
from [email protected] I'll dump this here.
Depending on the placement of a label Gcc gives a false positive warning
about misleading indentation. Below is a minimal working example to
reproduce and the output from Gcc.
Arsen Arsenović was so kind to confirm (on IRC) this bug is reproducible
with a current Gcc and asked me to report it.
/*
* miside.c
* MWE for a wrong warning shown with gcc -Wmisleading-indentation
*/
void
good(int c)
{
label:
while (c != '-');
if (c != '-')
goto label;
}
void
bad(int c)
{
label: while (c != '-');
if (c != '-')
goto label;
}
/*
% gcc -c -Wmisleading-indentation miside.c
miside.c: In function ‘bad’:
miside.c:18:9: warning: this ‘while’ clause does not guard...
[-Wmisleading-indentation]
18 | label: while (c != '-');
| ^~~~~
miside.c:19:9: note: ...this statement, but the latter is misleadingly indented
as if it were guarded by the ‘while’
19 | if (c != '-')
| ^~
*/