[clang++] GCC/clang difference

I have a question regarding the following code:

template<typename T>
struct A
{
    const static int type;
};

template<typename T>
struct B
{
    typedef A<T> C;
};

typedef B<int>::C D;
//const int D::type = 2;
template<> const int D::type = 2;

int main()
{
    B<int> b;
}

gcc 4.5 and 4.6(beta) require the "template<>" in front of "const in D::type = 2" with the error "error: specializing member 'A<int>::type' requires 'template<>' syntax"

gcc 4.3 and 4.4 give the error "too few template-parameter-lists"

clang++ (trunk 121734) gives an error if the "template<>" is present.

Can someone point me to the relevant section of the standard defining the required behavior here? I'm trying to determine where to submit an issue report.

Thanks
Nate Knight

Hi Nate-

This would appear to be covered in §14.7.3 (temp.expl.spec) which says that GCC is right.

Alistair

This area of the standard is a complete mess. Check out

  C++ Standard Core Language Active Issues

which deals with the same issue and has various pointers into the (contradictory) passages in the working paper. Clang was meant to follow the proposed resolution of this core issue.

  - Doug