Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

“a derived class is not allowed here”

$
0
0

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


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>