http://llvm.org/bugs/show_bug.cgi?id=8748

           Summary: Default template arguments in out-of-line member
                    definitions not rejected.
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


Clang does accept both of the following

// Testcase 1
struct A { template<typename U> struct B; }; 
template<typename U = int> struct A::B { };

// Testcase 2
template<typename T> struct A { template<typename U> struct B; }; 
template<typename T> template<typename U = int> struct A<T>::B { };

The draft standard n3225 however says at [temp.param]p9 (and C++03 uses wording
too, to that effect there):

"A default template-argument shall not be specified in the
template-parameter-lists of the definition of a member of a class template that
appears outside of the member's class."

So Testcase 2 seems to be ill-formed. Incidentally, Clang doesn't compile
Testcase 2 if we want to make use of the default argument, as in "A<int>::B<>". 

I'm not exactly sure how much of it is QoI and how much is required to be
diagnosed. If we do *not* make use of the default argument, then clang doesn't
complain at all if we say "A<int>::B<int>". 

However here the ill-formeness doesn't occur in the definition of the default
argument, but with its mere presence in the definition, so if we require the
definition of "A<int>::B" but not the definition of the default argument, I
can't clearly cut the border of where required diagnostics end and QoI starts.
It would seem to be easy to diagnose the default argument nontheless to me,
already when its definition is parsed.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to