In the following test program, the specialization of the function-template
"first_of" declares an unused template parameter Y which causes a link error.
This "soft" failure is very hard to debug in functions with more than one
argument and with (levels of) nested templates. It would be helpful to have the
compiler flag this as an unused-template-parameter warning in specializations.
This should probably not be flagged as an error because template parameters,
whether used or unused, serve a purpose in template-metaprogramming.
Compilation command: g++ -Wall <cpp-file>
--------------------------
// declare
template<typename X, typename Y>
X& first_of(X & x, Y & y);
// specialize
template<typename X, typename Y /*note:unused*/ >
X& first_of(X & x1, X & x2) { return x1; }
int main(void)
{
double a(5.0), b(6.0);
double &a_also = first_of(a,b);
(void) a_also;
return 0;
}
----------------------------------
--
Summary: Unused template parameter in function-template
specialization causes link error
Product: gcc
Version: 4.2.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rmanoj at umich dot edu
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43386