Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
7568 Discussions

ICC can't deduct template type where gcc and clang can

moreno__eduardo
Beginner
198 Views

The following code is failing on ICC 18.0.3, while it works fine on gcc 4.8.5, clang  3.4.2, MS Visual Studio 2017:

  • file.h
template<typename HeadNodeType>
static void addFetaCoefficientsForHeadNodes(
    HeadNodeType const &headNode,
    Path const &path,
    std::string const &attributeName,
    Coefficients const &coeffs,
    FetaTuplesMap<HeadNodeType, Path> &fetaHeadNodeMap);
  • file_impl.h (Implementation is made in a separate header file to keep the main header cleaner)
template<typename HeadNodeType>
void Objective::addFetaCoefficientsForHeadNodes(
    HeadNodeType const &headNode,
    Path const &path,
    std::string const &attributeName,
    Coefficients const &coeffs,
    FetaTuplesMap<HeadNodeType, Path> &fetaHeadNodeMap)
  • file.cpp (using the previous)
void Objective::addFetaCoefficients(
    SourceNode const &sourceNode,
    Path const &path,
    std::string const &attributeName,
    Coefficients const &coeffs)
{
    addFetaCoefficientsForHeadNodes(sourceNode, path, attributeName, coeffs, m_fetaSourceNodeMap);
}
void Objective::addFetaCoefficients(
    StockpileNode const &stockpileNode,
    Path const &path,
    std::string const &attributeName,
    Coefficients const &coeffs)
{
    addFetaCoefficientsForHeadNodes(stockpileNode, path, attributeName, coeffs, m_fetaStockpileNodeMap);
}

The issue is:

file.cpp(31): error: no instance of function template "Objective::addFetaCoefficientsForHeadNodes" matches the argument list

            argument types are: (const SourceNode, const Path, const std::string, const Coefficients, FetaMapSourceNode)
        addFetaCoefficientsForHeadNodes(sourceNode, path, attributeName, coeffs, m_fetaSourceNodeMap);
        ^
file_impl.h(16): note: this candidate was rejected because at least one template argument could not be deduced
  void Objective::addFetaCoefficientsForHeadNodes(

As explained, this works fine on any other of the named compilers. It doesn't even work by expliciting the types in the functions calls in the cpp file, as:

addFetaCoefficientsForHeadNodes<SourceNode>(sourceNode, path, attributeName, coeffs, m_fetaSourceNodeMap);
...
addFetaCoefficientsForHeadNodes<StockpileNode>(stockpileNode, path, attributeName, coeffs, m_fetaStockpileNodeMap);

 

 

 

0 Kudos
3 Replies
Viet_H_Intel
Moderator
198 Views

Can you please provide your command line options and show us how to compile your test case?

Thanks,

Viet

moreno__eduardo
Beginner
198 Views

The command line used to compile is this:

/opt/intel/compilers_and_libraries/linux/bin/intel64/icc -I/usr/local/include -I/home/apalma/MinePlanner/CMPicc/OPP/include -I/opt/ibm/ILOG/CPLEX_Studio128/cplex/include/ilcplex -I/opt/gurobi801/linux64/include -fmax-errors=1 -Wextra -march=native -std=c++11 -DTIMING -pedantic-errors -Wall -Werror -O3 -DNDEBUG -s -fPIC -o CMakeFiles/opp_static.dir/opp_objective.cpp.o -c /home/apalma/MinePlanner/CMPicc/OPP/src/opp_objective.cpp

 

Viet_H_Intel
Moderator
198 Views

 

Can you provide us a complete test case? I am having other compilation issues with those files you provided on Friday.

Or you can give us a preprocess file by running the below command:

/opt/intel/compilers_and_libraries/linux/bin/intel64/icc -I/usr/local/include -I/home/apalma/MinePlanner/CMPicc/OPP/include -I/opt/ibm/ILOG/CPLEX_Studio128/cplex/include/ilcplex -I/opt/gurobi801/linux64/include -fmax-errors=1 -Wextra -march=native -std=c++11 -DTIMING -pedantic-errors -Wall -Werror -O3 -DNDEBUG  -fPIC  -E /home/apalma/MinePlanner/CMPicc/OPP/src/opp_objective.cpp >& testcase.i

 

Thanks,

Viet

Reply