“a derived class is not allowed here”

“a derived class is not allowed here”


here is another code snippet which does not compile with ICC (version 14.0.2 on Linux) but does compile with GCC and Clang:

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>;    // explicit instantiation

The error message is:

$ 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 got some help with this code snippet on stackoverflow.com (c.f. http://stackoverflow.com/q/22479641/1132850) and believe this is a compiler bug.

Note that instantiating an object instead of explicit instantiation does compile:

void foo()

Best regards


3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Here is a simpler snippet to reproduce 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>;


Hello Raimer,

I have reproduced as you said ,and have entered this issue into our problem-tracking database.Thank you for submitting the issue.I'll get this posted whenever I have an update from development team.

Thank you.
Intel Developer Support

Please participate in our redesigned community support web site:

User forums:                   http://software.intel.com/en-us/forums/


Leave a Comment

Please sign in to add a comment. Not a member? Join today