Live data from Hacker News

The Apple goto fail vulnerability: lessons learned (2014)

dwheeler.com

1–10 of 42 posts

Re: The Apple goto fail vulnerability: lessons learned (2014)

#4
post #2

One of the ideas to make this error visible is to forbid misleading indentation (section 3.5). It would be cool if the IDE can show this goof straight away..

These days, both GCC and Clang have a compiler warning about it:

https://developers.redhat.com/blog/2016/02/26/gcc-6-wmislead...

However, for some reason, while GCC puts it under -Wall, Clang (which Apple uses) doesn't enable it even with -Wall -Wextra; you have to manually add -Wmisleading-indentation. It's also not enabled by the default Xcode template.

Re: The Apple goto fail vulnerability: lessons learned (2014)

#6

For as long as I live, I’ll never understand style guides that permit omitting brackets around a single line following an if statement (or for, while, etc), nor code formatters that dont automatically insert them.

I agree - it should be a compile or runtime error.

Re: The Apple goto fail vulnerability: lessons learned (2014)

#7

For as long as I live, I’ll never understand style guides that permit omitting brackets around a single line following an if statement (or for, while, etc), nor code formatters that dont automatically insert them.

I agree - it should be a compile or runtime error.

Well if you compile with `-Werror -Wall` (and you should), it would throw in error in GCC 6+:

https://developers.redhat.com/blog/2016/02/26/gcc-6-wmislead...

Re: The Apple goto fail vulnerability: lessons learned (2014)

#8

For as long as I live, I’ll never understand style guides that permit omitting brackets around a single line following an if statement (or for, while, etc), nor code formatters that dont automatically insert them.

It can make code bloated and harder to follow.

TBH it would be nice if someone made C with indent scoping instead of block scoping but I don’t think that’s truly practical with the preprocessor.

Re: The Apple goto fail vulnerability: lessons learned (2014)

#10

For as long as I live, I’ll never understand style guides that permit omitting brackets around a single line following an if statement (or for, while, etc), nor code formatters that dont automatically insert them.

They add visual noise. The grammar of C is not the same as the grammar of it's offshoots and block statements aren't part of control structures. Moreover, GCC warns about extra statements with the same indentation level with -Wall on.
Post reply on HN