Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7679 Discussions

“a derived class is not allowed here”

Raimar_S_
Beginner
309 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
309 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>;

 

QIAOMIN_Q_
New Contributor I
309 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/

 

Reply