error #308 when specializing private nested class outside of class declaration

error #308 when specializing private nested class outside of class declaration

When a nested private template class is specialized outside the declaration of the parent class, the intel compiler issues an error #308. clang and vc110 compile the same code.

If I make the same nested template class public, the intel compiler compiles it as well.

That doesn't make sense to me: You wouldn't want to declare a nested template class public just because you want to specialize it outside, right? Is this a known issue?

I have Intel Composer 2013, Version 13.1.3.198 Build 20130607.

(If necessary, I can make a toy example.)

 

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

>>...When a nested private template class is specialized outside the declaration of the parent class, the intel compiler
>>issues an error #308...
>>...
>>...If necessary, I can make a toy example...

A test case is needed to investigate what could be possibly wrong and please post it.

//-----------------------------------------------------
template<class T>
struct A {
private:
    template<class U> struct B
    {
        static int v() { return 0; }
    };
public:
    template<class U>
    static int foo()
    {
        return B<U>::v();
    }
};

template<class T> template<class U>
struct A<T>::B<U*>
{
    static int v() { return 1; }
};

#include <iostream>

int main()
{
    std::cout << A<int>::foo<int*>() << std::endl;
}

This leads to

error #308: class template "A<T>::B [with T=int]" (declared at line 5) is inaccessible
1>    struct A<T>::B<U*>
1>                 ^
1>            detected during instantiation of class "A<T> [with T=int]" at line 27
1> 

 

Thanks for the small test case. This does indeed look like a bug, I have entered it into our bug tracking database as DPD200248044.

Judy

Thank you. Could I get a link to that database, please?

 

Sorry, but due to privacy concerns only Intel employees can access the database. We will keep you posted when it is fixed.

thanks, Judy

Oh ok. I get the ID but all getters are private. Can't be helped. :)

Any update on issue DPD200248044?

 

In the newest Composer XE2013 SP1 update 3 from last week, this issue persists. Can you give me an estimation when this will be fixed?

This is kind of a show-stopper for us for actually using the Intel Compiler because we have a third-party header-only template library where the code pattern in the example is used everywhere.

 

Hello Weibke,

We have worked out a fix in the next update ,which would be released until the end of July .

However ,there is a simple workaround -- you can declare the nested class public instead of private.

If you need to do this is lots of places and/or don’t want to touch third party code I think you could just put –Dprivate=public on the command line to change ALL private members to public members. It probably wouldn’t be good to do this when your code is under development but if all you are trying to do is get some code to build with our compiler for performance testing purposes then that should work.

 

 

Thank you.
--
QIAOMIN.Q
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