https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69993
Bug ID: 69993 Summary: Misleading wording for -Wmisleading-indentation 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: --- Reddit user "sysop073" observed here: https://www.reddit.com/r/programming/comments/47pejg/gcc_6_wmisleadingindentation_vs_goto_fail/d0eonwd that the wording of -Wmisleading-indentation is rather confusing: > The way they split up the warning looks designed to trick you. > sslKeyExchange.c:631:8: warning: statement is indented as if it were guarded > by... [-Wmisleading-indentation] > goto fail; > ^~~~ > sslKeyExchange.c:629:4: note: ...this 'if' clause, but it is not > if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) > ^~ > You read the first half and it sounds like goto fail; is guarding something. > Why would it not be: > sslKeyExchange.c:631:8: warning: statement is wrongly indented... > [-Wmisleading-indentation] > goto fail; > ^~~~ > sslKeyExchange.c:629:4: note: ...as if it were guarded by this 'if' clause > if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) > ^~ I agree that the current wording is suboptimal. I think the wording would be much clearer if the wording of the "warning" only spoke about the statement in question, and the "note"/inform should then talk about the not-really-guarding guard. I think my preferred wording would be: sslKeyExchange.c:631:8: warning: statement is misleadingly indented... [-Wmisleading-indentation] goto fail; ^~~~ sslKeyExchange.c:629:4: note: ...as if it were guarded by this 'if' clause, but it is not if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) ^~