Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Christoph_P_1
Beginner
80 Views

integer constant as template parameter problem

Compiling pcl-1.7.2 with intel c++ compiler 15.0.4.221 Build 20150407 on Windows failed with errors related to Eigen-3.2.4.
I was able to reduce the problem to the following code snippet. It uses an integer constant as parameter of a template type. This type is used as the return type of a template classes member function. The intel c++ compiler reports a mismatch between declaration and definition of this member function. But Microsoft compiler, gcc and I agree, that there is no mismatch. Is this an intel c++ compiler problem?
(For those interested: I found a workaround by defining the integer constant with enum { ... } instead of int const ...).

namespace MyNamespace {
  int const MyConstant=42; // this leads to error in line 19 with intel compiler
  // enum {MyConstant=42};      // ok with intel compiler
  
  template<typename A, int B> class MyRetVal
  {
  };


  template<typename A>
  class MyClass
  {
  public:
    MyRetVal<A,MyConstant> func();
  };
  

  template<typename A>
  MyRetVal<A,MyConstant> MyClass<A>::func() // <-- error with intel compiler
  {
    MyRetVal<A,MyConstant> m;
    return m;
  }
}


int main()
{
  MyNamespace::MyClass<float> a;
  a.func();
  return 0;
}

 

Here is the compiler error message:

  Intel(R) C++ Compiler XE for applications running on IA-32, Version 15.0.4.221 Build 20150407
  Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

  intel_template.cpp
  intel_template.cpp(19): error: declaration is incompatible with "MyNamespace::MyRetVal<A, MyNamespace::MyConstant> MyNamespace::MyClass<A>::func()" (declared at line 14)
      MyRetVal<A,MyConstant> MyClass<A>::func() // <-- error with intel compiler

compilation aborted for intel_template.cpp (code 2)

0 Kudos
1 Reply
Brandon_H_Intel
Employee
80 Views

Hi Christoph,

This looks like an issue with the Intel compiler. I have submitted a problem report to our front end team (defect id DPD200371447). I'll let you know when there's more to report here.

Reply