Bug#747345: impliedness of -Wunused-parameter depends on -W option ordering
Package: gcc-4.8
Version: 4.8.2-21
Whether various combinations of options imply -Wunused-parameter in
the presence of -Wno-unused depends on where on the command line
-Wno-unused appears:
sid$ cat tt.c
void foo(int x) { }
sid$ gcc -g -O2 -Wall -Wno-unused -W -c tt.c
sid$ gcc -g -O2 -Wall -W -Wno-unused -c tt.c
tt.c: In function 'foo':
tt.c:1:14: warning: unused parameter 'x' [-Wunused-parameter]
void foo(int x) { }
^
sid$
This is confusing, to say the least. It doesn't appear to be
discussed in the documentation, and differs from 4.7.2:
wheezy$ gcc -g -O2 -Wall -Wno-unused -W -c tt.c
wheezy$ gcc -g -O2 -Wall -W -Wno-unused -c tt.c
wheezy$
I think this new behaviour is counterintuitive and I prefer the old
behaviour. But if the new behaviour is considered desirable, the
exact semantics should be explained. I did some quick experiments,
but I haven't been able to come up with a coherent explanation.
Consider, for example, this, which is all what I would have expected
but appears not to be consistent with the sid transcript above:
sid$ gcc -g -O2 -Wunused -W -c tt.c
tt.c: In function 'foo':
tt.c:1:14: warning: unused parameter 'x' [-Wunused-parameter]
void foo(int x) { }
^
sid$ gcc -g -O2 -W -Wunused -c tt.c
tt.c: In function 'foo':
tt.c:1:14: warning: unused parameter 'x' [-Wunused-parameter]
void foo(int x) { }
^
sid$ gcc -g -O2 -W -c tt.c
sid$ gcc -g -O2 -W -Wunused -Wno-unused -c tt.c
sid$ gcc -g -O2 -Wunused -W -Wno-unused -c tt.c
sid$
Thanks,
Ian.
Reply to: