Home Internal compiler error on a template function specialization
Reply: 1

Internal compiler error on a template function specialization

Humam Helfawi
1#
Humam Helfawi Published in 2018-01-13 01:52:01Z

I have a code that worked on Lunix/GCC. However, when compiling on Windows/MSVC 2017, I am facing an internal compiler error:

.hpp:

namespace g2o {
namespace internal {

    template<typename MatrixType>
    inline void axpy(const MatrixType& A, const Eigen::Map<const Eigen::VectorXd>& x, int xoff, Eigen::Map<Eigen::VectorXd>& y, int yoff) {
        y.segment<MatrixType::RowsAtCompileTime>(yoff) += A * x.segment<MatrixType::ColsAtCompileTime>(xoff);
    }

    template<int t>
    inline void axpy(const Eigen::Matrix<double, Eigen::Dynamic, t>& A, const Eigen::Map<const Eigen::VectorXd>& x, int xoff, Eigen::Map<Eigen::VectorXd>& y, int yoff) {
        y.segment(yoff, A.rows()) += A * x.segment<Eigen::Matrix<double, Eigen::Dynamic, t>::ColsAtCompileTime>(xoff);
    }

    template<> /*******ERROR HERE*******/
    inline void axpy(const Eigen::MatrixXd& A, const Eigen::Map<const Eigen::VectorXd>& x, int xoff, Eigen::Map<Eigen::VectorXd>& y, int yoff) {
        y.segment(yoff, A.rows()) += A * x.segment(xoff, A.cols());
    }   
} // end namespace internal
} // end namespace g2o

I saw solution telling that I should do the following:

template<Eigen::MatrixXd> inline void axpy<Eigen::MatrixXd> ....

However, it did not work.


Error message as it was produced by the compiler:

Error C1001 An internal error has occurred in the compiler.

Minor Threat
2#
Minor Threat Reply to 2018-01-13 02:15:34Z

From my experience with MSVC++, it doesn't handle long inputs as well as other compilers. It likes compact compilation units and PCH (Pre-Compiled Headers). Because templates are always header-only, they usually cause lots or recursive #include directives and long compilation unit as a result. MSVC++ sometimes can't handle that and cause an Internal Compiler error. IMHO this is your case. Decoupling code to few compilation units, extensive use of forward declarations and Pimpls and moving #include directives from *.hpp to *.cpp usually worked for me.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.317136 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO