I am using ICC 14.0.2 for Linux. This piece of code is compiled using GCC and CLang, but not ICC:
template<int N, bool B> struct A; template<int N> struct A<N,false> { template<int M> struct Nested {}; }; template<int N> struct A<N,true> : public A<N,false> {}; template struct A<1,true>::Nested<2>;
Trying to compile this with three compilers:
$ g++ -c -std=c++11 testcase.cc $ clang++ -c -std=c++11 testcase.cc $ icpc -c -std=c++11 testcase.cc testcase.cc(17): error: invalid qualifier for "A<1, false>::Nested<2>" (a derived class is not allowed here) template struct A<1,true>::Nested<2>; ^ compilation aborted for testcase.cc (code 2)
I did not find useful information about this error message.
In my case, explicit instantiation (of more complex classes) is part of the unit test, and I can get around the problem by creating an instance of an object that ICC happily compiles:
void foo() { A<1,true>::Nested<2>(); }
However, I would like ICC to be right with its error or it is a compiler error.
Thank you for your time!
Update Thanks to Philip for a detailed analysis. I reported this issue to Intel developers. Indeed, partial specialization has nothing to do with the problem (as I suspected earlier), so even this simpler snippet reproduces the problem:
template<int N> struct A { template<int M> struct Nested {}; }; template<int N> struct B : public A<N> {}; template struct B<1>::Nested<2>;
c ++ language-lawyer compiler-errors icc
PiQuer
source share