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

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

Wiebke_T_
Beginner
841 Views

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.)

 

0 Kudos
9 Replies
SergeyKostrov
Valued Contributor II
841 Views
>>...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.
0 Kudos
Wiebke_T_
Beginner
841 Views

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

0 Kudos
Judith_W_Intel
Employee
841 Views

 

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

0 Kudos
Wiebke_T_
Beginner
841 Views

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

0 Kudos
Judith_W_Intel
Employee
841 Views

 

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

thanks, Judy

0 Kudos
Wiebke_T_
Beginner
841 Views

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

0 Kudos
Wiebke_T_
Beginner
841 Views

Any update on issue DPD200248044?

 

0 Kudos
Wiebke_T_
Beginner
841 Views

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.

 

0 Kudos
QIAOMIN_Q_
New Contributor I
841 Views

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/

 

0 Kudos
Reply