Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

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

$
0
0

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.

AttachmentSize
Downloadtext/x-c++srcrfa.cpp236 bytes
Downloadtext/x-c++srcRFASolver.cpp290 bytes
Downloadtext/x-chdrRFASolver.h301 bytes

TCE Open Date: 

Tuesday, February 25, 2020 - 08:49

Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>