Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Intel C++ Compiler rejects presumably valid code with out-of-line template member function definition

Mikhail_M_1
Beginner
432 Views

Intel C++ Compiler (EDG-based frontend) rejects the following code:

template <typename Descriptor>
class hash_table
{
public:
  typedef int value_type;

  template <typename Argument, int Callback (value_type *, Argument)>
  void traverse (Argument);
};

template <typename Descriptor>
template <typename Argument, int Callback (typename hash_table <Descriptor>::value_type *, Argument)>
void hash_table <Descriptor>::traverse (Argument) {}

with the following error message:

$ /opt/intel/bin/icpc -v
icpc version 16.0.0 (gcc version 4.9.0 compatibility)
$ /opt/intel/bin/icpc -c test.cc 
test.cc(13): error: declaration is incompatible with function template "void hash_table<Descriptor>::traverse<Argument,Callback>(Argument)" (declared at line 8)
  void hash_table <Descriptor>::traverse (Argument) {}
                                ^

compilation aborted for test.cc (code 2)

Both GCC 4.9.x and later and Clang 3.7 accept this code. See also: question on Stack Overflow.

0 Kudos
2 Replies
Feilong_H_Intel
Employee
432 Views

Hi Mikhail,

I've escalated this issue to our engineering team.  Thank you for your small test case.

0 Kudos
Feilong_H_Intel
Employee
432 Views

Hi Mikhail,

This issue has been fixed in the latest 16.0 compiler update.  FYI.

0 Kudos
Reply