------- Comment #2 from rmanoj at umich dot edu  2010-03-16 14:37 -------
The issue is not whether the type can be deduced or how to invoke template
specialization so that the deduction is correctly performed. Rather it is about
complex template specifications where such specifications are cumbersome and
bugs are difficult to detect by the eye - a warning would at least alert the
user that this might be an issue.

Consider the following declaration and specialization:

template<typename YY, typename AA, typename XX, typename ZZ>
        void YmAX(YY const& Y /*-*/, AA const& A, XX const& X, /*->*/ ZZ & Z);

template<typename TY, typename LY, typename AY, typename TA,
        typename TX, typename LX, typename AX, typename TZ, typename LZ,
typename AZ>
        inline
        void YmAX(UBLAS_NS::diagonal_matrix<TY,LY,AY> const& Y,
                  TA const& A,
                 
UBLAS_NS::matrix_range<UBLAS_NS::matrix<TX,UBLAS_NS::column_major,AX> const>
const& X,
                 
UBLAS_NS::matrix_range<UBLAS_NS::matrix<TZ,UBLAS_NS::column_major,AZ> > & Z)
{ ... }


In the specialization, two parameters LX and LZ are unused. The (T?,L?,A?)
triplet is used to specialize a matrix class and this case, LX and LZ are
actually partially specialized-out using UBLAS_NS::column_major (this mistake
is due to copy-paste, say).

The full specialization invocation is of the form YmAX<(very complicated, long
spec)> which is wrong for this application because LX and LZ should not even be
used and when they are not, GCC performs type-deduction correctly with the call
to YmAX() without any explicit specialization args at invocation.

So my point is that a warning will help greatly with identifying bugs in very
complex, nested template expressions like in boost.

The original snippet I posted, for example, compiles fine but fails at link.
One would, for the most part, expect compile failures with template code and
would search in the wrong place after getting a link failure, least of all in
the template parameter decl list, in my opinion. It took me a day to stop
looking a the function body and cross-examine the parameter decl list.

I request reconsideration for at least a warning that might be toggled with a
flag (say -Wunused-template-parameter).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43386

Reply via email to