[LLVMbugs] [Bug 14162] New: Template expression ambiguous in main, but not in subroutine

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Oct 23 13:21:04 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=14162

             Bug #: 14162
           Summary: Template expression ambiguous in main, but not in
                    subroutine
           Product: clang
           Version: 3.1
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: rhl at astro.princeton.edu
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn),
but the pre-processed source fails the same way at http://llvm.org/demo/

The following code fails to compile with the error message:

eigen_lu.cc:29:7: error: use of overloaded operator '=' is ambiguous (with
operand types 'Eigen::Map<Eigen::VectorXd>' and 'const
internal::solve_retval<PartialPivLU<Matrix<double, -1, -1, 0, -1, -1>>,
      Matrix<double, -1, 1, 0, -1, 1>>')
    c = lu.solve(b);
    ~ ^ ~~~~~~~~~~~
eigen_lu.cc:33:15: note: in instantiation of function template specialization
'ApproximateChebyshev<double>' requested here
template void ApproximateChebyshev<double>();
              ^
/u/lsst/products/DarwinX86/eigen/3.0.2+1/include/Eigen/src/Core/MatrixBase.h:167:14:
note: candidate function [with OtherDerived =
     
Eigen::ReturnByValue<Eigen::internal::solve_retval_base<Eigen::PartialPivLU<Eigen::Matrix<double,
-1, -1, 0, -1, -1>>, Eigen::Matrix<double, -1, 1, 0, -1, 1>>>]
    Derived& operator=(const DenseBase<OtherDerived>& other);
             ^
/u/lsst/products/DarwinX86/eigen/3.0.2+1/include/Eigen/src/Core/MatrixBase.h:170:14:
note: candidate function [with OtherDerived =
     
Eigen::ReturnByValue<Eigen::internal::solve_retval_base<Eigen::PartialPivLU<Eigen::Matrix<double,
-1, -1, 0, -1, -1>>, Eigen::Matrix<double, -1, 1, 0, -1, 1>>>]
    Derived& operator=(const EigenBase<OtherDerived>& other);
             ^
/u/lsst/products/DarwinX86/eigen/3.0.2+1/include/Eigen/src/Core/MatrixBase.h:173:14:
note: candidate function [with OtherDerived =
     
Eigen::internal::solve_retval_base<Eigen::PartialPivLU<Eigen::Matrix<double,
-1, -1, 0, -1, -1>>, Eigen::Matrix<double, -1, 1, 0, -1, 1>>]
    Derived& operator=(const ReturnByValue<OtherDerived>& other);


If I put the same 2 lines into a subroutine, all is well.  

/////////////////////////////////////////////////////////////
#include <vector>
#include "Eigen/Core"
#include "Eigen/LU"

void
solveLU(Eigen::MatrixXd &A,
        Eigen::VectorXd &b,
        Eigen::Map<Eigen::VectorXd> &c
       )
{
    Eigen::PartialPivLU<Eigen::MatrixXd> lu(A);
    c = lu.solve(b);
}

template<typename PixelT>
void
ApproximateChebyshev()
{
    int const nTerm = 10;
    Eigen::MatrixXd A;
    Eigen::VectorXd b;
    std::vector<double> cvec(nTerm);
    Eigen::Map<Eigen::VectorXd> c(&cvec[0], nTerm);

#if 0
    solveLU(A, b, c);
#else  // inlining these two statements doesn't compile
    Eigen::PartialPivLU<Eigen::MatrixXd> lu(A);
    c = lu.solve(b);
#endif
}

template void ApproximateChebyshev<double>();
/////////////////////////////////////////////////////////////

I'm attaching the pre-processed source.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list