Is there any flag in GCC (like -Wempty-body
in clang), that could help me detect semicolons after the braces of while/for loops? Sometimes it is very hard for humans to find these simple mistakes.
int i = 0;
for (i = 0; i < 10; ++i);
{
cout << i << endl;
}
I use GCC 4.7.3 and clang 3.2-1~exp9ubuntu1.
Edited: I also check if compilers could help me find these mistakes after "if-else statements".
if (i == 0)
{
cout << i << endl;
}
else;
{
cout << i << endl;
}
What is interesting gcc is more helpful than clang (with this flags (-Wall -pedantic -Wempty-body
) by printing warning:
main.cpp:30:9: warning: suggest braces around empty body in an ‘else’ statement [-Wempty-body]
try
$gcc -Wempty-body foo.c
or
gcc -Wextra -c foo.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With