Hello clang,
I made a strange discovery with a small helper function I wrote:
If one test the following (short) program:
struct A;
void sink(A,int);
void func(A const& a, int x, int y) {
sink(a + x, y);
}
The following errors get emitted:
$ clang -fsyntax-only -Wunused-parameter unused_parameter.cpp
unused_parameter.cpp:15:11: error: invalid operands to binary expression (‘const A’ and ‘int’)
sink(a + x, y);
~ ^ ~
unused_parameter.cpp:14:34: warning: unused parameter ‘y’ [-Wunused-parameter]
void func(A const& a, int x, int y) {
^
1 warning and 1 error generated.
The first one is expected, however it seems its presence somehow short-circuit the analysis of the whole expression and as a result we get the spurious warning…
I feel that this is unwelcome, because it obfuscates the true error (especially since I tend to compile with -Werror).
For reference, I use the following version of Clang:
$ clang --version
clang version 3.0 (trunk 132889)
Target: i686-pc-mingw32
Thread model: posix
I could not find any mention of such an issue with my Google-fu in the cfe-dev archive, so please let me know if it already came up and it was deemed unimportant.
– Matthieu