GCC 6: -Wmisleading-indentation vs. “goto fail;”
developerblog.redhat.com
GCC 6: -Wmisleading-indentation vs. “goto fail;”
1–10 of 168 posts
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#2Omitting braces in this case leads to a lot of problems.
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#3Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#4This 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.
Using braces everywhere is definitely good style, but it isn't a practical solution because there's a ton of existing C/C++ code that doesn't use braces.
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#5Interesting. I would have assumed that this kind of check should be done by static analysers.
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#6This 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.
if (true)
foo();
else
bar();
This looks prettier to my eyes than if(true){
foo();
} else {
bar();
}
However, I might not be the last person to touch the code. My coworker might come later and add: if (true)
foo();
else
bar();
baz();
And hence the indent problem.Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#7This 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 warning is a practical solution to a real problem (of which the famous "goto fail" is an example). Using braces everywhere is definitely good style, but it isn't a practical solution because there's a ton of existing C/C++ code that doesn't use braces.
It would make sure that no new errors are introduced due to this.
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#8Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#9This 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.
I'm in favor of braces around everything, but to be honest even I will occasionally use the indent if I only expect one action. e.g. if (true) foo(); else bar(); This looks prettier to my eyes than if(true){ foo(); } else { bar(); } However, I might not be the last person to touch the code. My coworker might come later and add: if (true) foo(); else bar(); baz(); And hence the indent problem.
Re: GCC 6: -Wmisleading-indentation vs. “goto fail;”
#10This 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.
I'm in favor of braces around everything, but to be honest even I will occasionally use the indent if I only expect one action. e.g. if (true) foo(); else bar(); This looks prettier to my eyes than if(true){ foo(); } else { bar(); } However, I might not be the last person to touch the code. My coworker might come later and add: if (true) foo(); else bar(); baz(); And hence the indent problem.