Consider following short program:
int main() {
int a = 5, b = 1, c;
c = !a & b;
c = !a & 1;
return c;
}
Does anyone know why gcc gives a warning for c = !a & b;
but not for c = !a & 1;
?
$gcc -Wall test.c
test.c: In function 'main':
test.c:3:9: warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses]
c = !a & b;
My gcc version is 8.3.1 (I tried with one other version and the same thing happens).
I'm often surprised how 'smart' gcc is. And this one looks like a very easy problem to figure out. So why still a warning for the first one?