https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86157
Bug ID: 86157 Summary: Wmisleading-indentation disabled after a #line directive Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: chantry.xavier at gmail dot com Target Milestone: --- Created attachment 44279 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44279&action=edit test case with a block macro Today at work an instance of the "goto fail" bug was discovered and fixed (4 years after being introduced). We have a coding rule to enforce brackets even for single instructions, exactly to avoid that kind of bug. It's quite well respected, but we have no tool to check it. I learned about the Wmisleading-indentation feature, that is awesome ! But we already have gcc 6 and -Wall, and the bug was not found. That's because of that exception : "The warning is not issued after a #line directive, since this typically indicates autogenerated code, and no assumptions can be made about the layout of the file that the directive references.". That's a shame. We have a few #line directives in most of our files (compiled by gcc) because we use an apple extension called blocks (a kind of closure). More details at https://techtalk.intersec.com/2014/11/blocks-rewriting-with-clang/ So it would be great to have the Wmisleading-indentation feature even for files with #line directives, perhaps with another flag ? Any idea or suggestion or workaround is welcome. Well an easy workaround is to disable the #line directives just for running that check from time to time. So I just did that but still no warning, there is another problem, I just realized this case is more complex than it looked. See attachment for a simplified test case. Since the first line hides a block macro, the problem is not detected anyway.