> it’s been finding real world bugs One more case to support -Werror.
-Werror holds things back, because it makes the gcc maintainers hesitant to add more warnings on grounds of "it will break old code that uses -Werror", and in fact I was surprised to see that this warning is going into -Wall.
GCC 6: -Wmisleading-indentation vs. “goto fail;”
81–90 of 168 posts
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#82Nice. These sorts of warnings are why it's worth investing the extra effort to enable -Werror in your codebase if you can.
What's the difference if compilation stops at the warning? You'll (or your team, or whoever) fix it anyway, and if you won't, you have a people problem, that must be solved at the policy (or HR) level.
Solving people problems at the tooling level is a certain way to get unintended consequences and alienate the good people that weren't part of the problem. Of course, you can get some tooling to support your people, but tools to police them are worth less than zero.
Anyway, unrelated to that, I do like to live warnings on code that is not ready to production. It's an easy (effortless in fact) way to make sure it'll be fixed before deploying.
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#83This seems like it could have been avoided by people using braces around every block. Omitting braces in this case leads to a lot of problems.
This is the only item that I disagree with the Linux coding style ("Do not unnecessarily use braces where a single statement will do.")
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#84Earlier quoted context omitted.
I agree completely with this. After fighting over code formatting for so long (often starting those fights myself), I have thankfully come to realize that what format you use almost never matters, only that you use some standardized format.
And in the case of go that standard is language wide, not just project, team, or company wide.
If we ever move beyond using text files for storing code, we could eliminate formatting differences entirely... but efforts in that direction have run into many issues in the past.
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#85Making braces optional in single-statement if/else/while/for clauses is one of the biggest anti-features in C. It's frustrating that it was ported forward to more modern languages like Java, JavaScript, C#, etc. I'm glad Python (with semantic whitespace) and Go (with gofmt) solve this problem.
>I'm glad Python (with semantic whitespace)... solve this problem. Python solved it....then added the problem of making things you can't even see semantically significant. If you write Python, it's helpful to have an editor that makes the difference between tabs and spaces visible....
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#86Making braces optional in single-statement if/else/while/for clauses is one of the biggest anti-features in C. It's frustrating that it was ported forward to more modern languages like Java, JavaScript, C#, etc. I'm glad Python (with semantic whitespace) and Go (with gofmt) solve this problem.
if (a)
...
else ...
But for some reason I find the below _very_ frustrating. It feels misleading and I find it to be very, very ugly.if (a)
...
else { /* Multi line block */
}Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#87Making braces optional in single-statement if/else/while/for clauses is one of the biggest anti-features in C. It's frustrating that it was ported forward to more modern languages like Java, JavaScript, C#, etc. I'm glad Python (with semantic whitespace) and Go (with gofmt) solve this problem.
This is also one of the reasons I like Racket: there's no such thing as ambiguous block delimitation. Also, everything-is-an-expression is very useful.
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#88Making braces optional in single-statement if/else/while/for clauses is one of the biggest anti-features in C. It's frustrating that it was ported forward to more modern languages like Java, JavaScript, C#, etc. I'm glad Python (with semantic whitespace) and Go (with gofmt) solve this problem.
In Rust, code like this simply won't compile http://is.gd/e6mBlG
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#89You'd think a stand-alone program could take care of this quite nicely? No need to clutter the compiler itself.