Reputation: 19779
I was just curious if the following code should result in warning or not by g++ compiler:
// Snip #1
bool x = 0;
x++;
// Snip #2
switch (x) {
default:
printf("hi\n");
}
The problem is such statements exist in a legacy code i work upon :-|, I guess there should be some warnings for these?
I have g++-4.4.3c
Upvotes: 0
Views: 249
Reputation:
Incrementing a bool is a deprecated function, yet it is still valid and achieves the desired result, therefore a warning should not appear, it is just bad practice to do so.
Upvotes: 1
Reputation: 729
With gcc, -Wall does not actually turn on all warnings. The man page will cover all your options, but to be really thorough, use "-Wall -Weff-c++ -pedantic -Werror".
Upvotes: 1