Intel C++ compiler (icpc 14.0): "a derived class is not allowed here" -


i'm using icc 14.0.2 on linux. code snippet compiles gcc , clang, 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>;    // explicit instantiation 

trying compile 3 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 "a<1, false>::nested<2>" (a derived class not allowed here)   template struct a<1,true>::nested<2>;                              ^  compilation aborted testcase.cc (code 2) 

i couldn't find useful information error message.

in case, explicit instantiation (of more complicated classes) part of unit test, , can work around problem instantiating object instead, icc happily compiles:

void foo() {   a<1,true>::nested<2>(); } 

still if icc right error or whether compiler bug.

thanks time!

update thank filip detailed analysis. i reported issue intel developers. indeed partial specialization has nothing problem (as suspected), simpler snippet reproduces problem:

template<int n> struct {   template<int m>   struct nested {}; };  template<int n> struct b : public a<n> {};  template struct b<1>::nested<2>; 

note: gcc , clang showing correct behavior...


the bug in icc!

the snippet accepted both gcc , clang legal , should not trigger diagnostic.


the author responsible code inside icc issues provided diagnostic did trip on below snippet, taken standard, says names in base depends on template-parameter should not available inside definition of derived class.

14.6.2 dependent names [temp.dep]

3 in definition of class or class template, if base class depends on template-parameter, base class scope not examined during unqualified name lookup either @ point of definition of class template or member or during instantiation of class template or member.


as stated important note [temp.dep]p3 says base class scope not examined in definition of class, doesn't such names not inherited when being accessed outside.

your "work around" shows name (in case template<int> struct nested) indeed (correctly) inherited , available inside a<1, true>, icc seems confuse explicit instantiation rules of names inside definition of class.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -