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

Douglas Gregor dgregor at apple.com
Mon Dec 20 23:13:32 PST 2010


On Dec 20, 2010, at 1:54 PM, 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.

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

	http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#529

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



More information about the cfe-dev mailing list