I recently tested to build my code with clang instead of gcc. It fails, since I use -Werror because of an unused parameter in a template function. With gcc this does not happen.
Here is a small example:
template <typename REAL> int f(int a){return 42;}
int g(int a){return 42;}
Compiling it with clang give me the result I was hoping for:
$clang -c UnusedParam.cpp -Wunused-parameter
>UnusedParam.cpp:1:36: warning: unused parameter 'a' [-Wunused-parameter]
> template <typename REAL> int f(int a){return 42;}
> ^
>UnusedParam.cpp:3:11: warning: unused parameter 'a' [-Wunused-parameter]
> int g(int a){return 42;}
Gcc does only report the unused parameter in the second function.
$gcc -c UnusedParam.cpp -Wunused-parameter
>UnusedParam.cpp:3:5: warning: unused parameter ‘a’ [-Wunused-parameter]
> int g(int a){return 42;}
Is there a way to enforce a similar behavior? I would like gcc to generate the unused parameter warning as well.
Compiler:
- Clang: Version 3.3 (branches/release_33 183898)
- Gcc: Version 4.8.1 20130909