0

I'm trying the new Intel compiler 2018 a unlike every other compiler I have here this piece of code fails:

template<int power> double msqrT(double a) { return mpow(a, (double)power); };
template<> double msqrT<2>(double a) { return a*a; };
template<> double msqrT<3>(double a) { return a*a*a; };
template<> double msqrT<4>(double a) { return a*a*a*a; };

double x = msqrT<2>(y); 

For every specialization of the template it ends up with:

error : no instance of function template "msqrT" matches the specified type

Any idea why?

Vojtěch Melda Meluzín
  • 1,117
  • 3
  • 11
  • 22
  • You do not appear to be instantiating any templates. Can you provide a [mcve]? – IInspectable Mar 11 '18 at 12:29
  • I don't think that's relevant. I errors before an instantiation I think. Anyways sure, double x = msqrT<2>(y); This is pointless of course, but it is used inside other templates. – Vojtěch Melda Meluzín Mar 11 '18 at 12:39
  • If this is indeed a compiler bug, then you will need to report that. In that case, you'll need to provide a [mcve] anyway. So why not provide one now? – IInspectable Mar 11 '18 at 12:41
  • 3
    That's not a [mcve]. – IInspectable Mar 11 '18 at 12:52
  • The first google hits for `mpow` are for [an *integer* power](https://www.cprogramming.com/tips/tip/fastest-raise-to-power). Does your `mpow` really take a `double` argument? If I change it to `pow`, and include ``, your code compiles fine with ICC18 `-Wall -O3 -march=haswell`: https://godbolt.org/g/NE4k9c (of course without the nonsense `double x = msqrT<2>(y);` at global scope!). – Peter Cordes Mar 12 '18 at 02:17
  • Thanks for the reply. mpow is indeed just pow. I'm redefining pretty much everything to make portability easier. Anyways I tried and it indeed does work. I tried to mess with the "big code", but it's just gigantic, so I gave up for now. I'm not really sure where the difference could be. Looks like it may be a bug in ICC related to some unrelated code around. – Vojtěch Melda Meluzín Mar 12 '18 at 10:42

0 Answers0