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

“a derived class is not allowed here”

Raimar_S_
Beginner
512 Views

Hi,

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()
{
  A<1,true>::Nested<2>();
}

Best regards

Raimar

0 Kudos
2 Replies
Raimar_S_
Beginner
512 Views

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>;

 

0 Kudos
QIAOMIN_Q_
New Contributor I
512 Views

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.
--
QIAOMINQ.
Intel Developer Support

Please participate in our redesigned community support web site:

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

 

0 Kudos
Reply