Live data from Hacker News

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

developerblog.redhat.com

81–90 of 168 posts

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

#81
post #17

> 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.

I use -Werror and I strongly hope maintainers keep adding new warnings. The cleaner the code, the better! If it is really necessary, you can disable specific warnings with pragmas.

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

#82
post #11

Nice. These sorts of warnings are why it's worth investing the extra effort to enable -Werror in your codebase if you can.

No, I've never seen a real use case for -Werror.

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;”

#83
post #26
post #2

This 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.")

There is a lot to dislike in the Linux coding style... and yes, this is one.

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

#84
post #66

Earlier 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.

I think that's one of the best contributions golang has made to the programming world. The idea that the language itself should be easy and unambiguous for the compiler and the human to parse. And that a single formatting standard makes life easier for everyone.

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;”

#85

Making 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....

[deleted]

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

#86

Making 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 don't find something like the below frustrating really

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;”

#87

Making 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 agree. I've trained myself to religiously apply curly braces to all blocks, but it'd be more reassuring to know there was a compiler check for it. I do have linters set up to check for it, but I just wish it were default.

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;”

#88

Making 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

Well, yeah, but that's not a huge advantage of Rust. In any language where that's not an allowed construct (and there's quite a few), it won't compile. It won't compile in Perl either (It fails at the compilation stage, not at runtime).
Post reply on HN