crash on template struct

Xiaowen Wang swangken at cfdlab.ae.utexas.edu
Mon Apr 24 21:44:57 BST 2000


Hi:
I was using Kdevelop1.0-3 quite coming with LinuxMandrake quite happily
recently. But today, kdevelop crashed on a template structure
definition. I tried to work it around by modifying the struct's
definition, but it's still working very sensitively to some template
usage.

Here's my original code which kdevelop didn't like at all, and I found
what it actually didn't like is the partial specialization:

  template < class _Tval, int _Nrows, int _Ncols, bool _is_row_major
=false> struct _Dotter;
 
  // do dot product for column_major matrix' row with vector
  template < class _Tval, int _Nrows, int _Ncols >
  struct _Dotter<_Tval,_Nrows,_Ncols,false> {
    _Dotter(const _Tval* mat, const _Tval* vec) :_mat(mat), _vec(vec) {}
    inline _Tval operator () const {
      toolbox::strided_iterator<const _Tval*,_Nrows> __from(_mat);
      ++_mat;
      return toolbox::inner_product<_Len>::apply(__from, _vec);
    }
    const _Tval *_mat, *_vec;
  };
 
  // do dot product for row-major matrix's row with vector
  template < class _Tval, int _Nrows, int _Ncols>
  struct _Dotter<_Tval,_Nrows,_Ncols,true>  {
    _Dotter(const _Tval* mat, const _Tval* vec) :_mat(mat), _vec(vec) {}
    inline _Tval operator () const {
      const _Tval* __from = _mat;
      _mat+=_Ncols;
      return toolbox::inner_product<_Len>::apply(__from, _vec);
    }
    const _Tval *_mat, *_vec;
  }; 

So after it crashed, I tried to adjust my code.
Here's the piece of code (actually it's only the constructor that chokes
it up) which I found kdevelop still crashed on:

  template < class _Tval, int _Nrows, int _Ncols, int _StrideDot, int
_StrideMove >
  struct _Dotter
  {
    typedef _Dotter<_Tval,_Nrows,_Ncols,_StrideDot,_StrideMove> _Self;
    _Dotter(const _Tval* mat, const _Tval* vec, _Tval coef=1)
:_mat(mat), _vec(vec), _coef(coef) {}
    _Dotter(const _Self& dotter) :_mat(dotter.mat), _vec(dotter.vec),
_coef(dotter._coef) {}
    inline _Tval operator () const {
      toolbox::strided_iterator<const _Tval*,_StrideDot> __from(_mat);
      _mat+=_StrideMove;
      return _coef*toolbox::inner_product<_Len>::apply(__from, _vec);
    }
    const _Tval *_mat, *_vec;
    _Tval _coef;
  };  


Thanks
Xiaowen




More information about the KDevelop mailing list