The following code snippet is related to the Apple bug of a few weeks ago.
void test( int a )
if ( a == 1 )
The original source code of the Apple bug has Goto’s instead of function calls, but the problem is essentially the same, and it is related to scoping.
I wonder if you considered convenient adding a warning if Clang detects that a line is indented so that does not match the natural indentation of its scope, especially there are a conditional around.
The following code is fine, no problem with it.
I think the followings cases should be warned by the compiler.
while (true) foo();
if (true) foo();
To emphasize the problem I attached a source code file. Could you give it a quick look and tell me what is printed out?
I know that it is an extreme and malicious example, but it help us to understand that when we given a quick look to the code, we can ignore cases like these.
Do you think it would be useful to add these warnings to Clang?
Thanks and regards,
apple_bug_clang.cpp (292 Bytes)