Malcolm: GCC 6: -Wmisleading-indentation vs “goto fail;”

By ris David Malcolm takes
a look
at a new compiler warning in GCC 6,
-Wmisleading-indentation. “At a high level, the underlying implementation looks at control statements (if/else, while, for), and if it sees them guard a single statement without braces, it looks at the followup statement. It complains if both have the same indentation.

That’s a simplified description – we spent a fair amount of time working on heuristics in the warning, to try to ensure that it warns for all cases that are reasonable to warn for, whilst not complaining unduly for indentation that’s merely bad (rather than being actively misleading). We’ve also tested it with a variety of coding styles: GNU, K&R, Linux kernel, etc.”

From: LWN

FacebookTwitterGoogle+LinkedInEvernotePocketGoogle Gmail