[cfe-dev] [clang++] GCC/clang difference

Alistair Lynn arplynn at gmail.com
Mon Dec 20 23:11:05 PST 2010


Hi Nate-

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

Alistair

On 20 Dec 2010, at 21:54, Nate Knight wrote:

> 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
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list