Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7679 Discussions

Undefined reference to explicitly instantiated template with template template parameter and alias template

Leoni__Massimiliano
590 Views

Hello everyone, I would like to report a bug in the Intel C++ compiler regarding alias templates.

I am attaching a MWE consisting of the following files:

// RFASolver.h

#ifndef RFASOLVER_H
#define RFASOLVER_H

class BioLinearisedSolver
{
};

template <typename BSP>
class RFALinearisedSolver
{
};

template <template <typename> class RFASolverPolicy, typename BioSolverPolicy>
class RFASolver
{
public:
    void run();
};

#endif /* end of include guard: RFASOLVER_H */

 

// RFASolver.cpp

#include "RFASolver.h"

template <template <typename> class RFASolverPolicy, typename BioSolverPolicy>
void RFASolver<RFASolverPolicy, BioSolverPolicy>::run()
{
}

template class RFALinearisedSolver<BioLinearisedSolver>;

template class RFASolver<RFALinearisedSolver, BioLinearisedSolver>;

 

// rfa.cpp

#include "RFASolver.h"

template <typename T>
using RFASolverPolicy = RFALinearisedSolver<T>;

int main(int argc, char* argv[])
{
    RFASolver<RFASolverPolicy, BioLinearisedSolver> rfaSolver;

    rfaSolver.run();

    return 0;
}

 

Now, this code compiles fine with g++, but with icpc version 19.0.1.144, compiling with

icpc -pedantic -std=c++14 -c RFASolver.cpp -o RFASolver.o
icpc -pedantic -std=c++14 -c rfa.cpp -o rfa.o
icpc -o rfa RFASolver.o rfa.o -pedantic -std=c++14

 

I get

 

rfa.cpp:(.text+0x30): undefined reference to `RFASolver<RFASolverPolicy, BioLinearisedSolver>::run()'

 

However, if I remove the alias template and use its value directly, as in

 

#include "RFASolver.h"

int main(int argc, char* argv[])
{
    RFASolver<RFALinearisedSolver, BioLinearisedSolver> rfaSolver;

    rfaSolver.run();

    return 0;
}

 

it links fine, meaning the bug seems to be related to the use of an alias template.

I understand users like me cannot report bugs directly, is this correct? Can you please report this bug?

In case this matters, I am compiling on an HPC cluster based on Intel architecture. I tried two different clusters and multiple versions of icpc and the result is always the same.

0 Kudos
6 Replies
PrasanthD_intel
Moderator
590 Views

Hi ,

I have tried to reproduce the issue with the files you have provided and the code ran without any errors with icpc compiler.

The icpc version i have used is icpc (ICC) 19.1 20200117. The bug might have been fixed in the latest version.

Could you provide the icpc versions you have tried with.

 

Thanks

Prasanth

 

Leoni__Massimiliano
590 Views
Hello Prasanth, thanks for your reply. As I mentioned in my original post, the most recent version I was able to reproduce the problem with was version 19.0.1.144.
PrasanthD_intel
Moderator
590 Views

Hi,

We don't find the issue in the latest version of icc . It compiled successfully.

Could you please upgrade your compiler to latest version (19.1) and confirm.

If you have any further issues, please get back to us.

 

Thanks

Prasanth

 

 

PrasanthD_intel
Moderator
590 Views

Hi

Thanks for reporting the bug.

We are closing this thread as the issue is resolved in the latest version of compiler.

Please raise a new thread if you face any new issues.

 

 

Thanks

Prasanth

Leoni__Massimiliano
590 Views
Hello Dwadasi, I am not a sysadmin on these machines so I cannot update the compiler. If you say it is fixed in the latest version, then it's ok, go ahead and close this thread. Thanks for the help!
PrasanthD_intel
Moderator
590 Views

Hi 

Thanks for the confirmation , the issue is fixed in latest version.

Please check when the version gets updated in your systems and reach out to us if you face any issues.

 

Thanks

Prasanth

 

Reply