Checking that a template-parameter is not used in its own default argument


I am trying to get into development on clang, and I thought I would try to fix a bug initially. I have written some code that partially implements the check in Sema/SemaTemplate.cpp in the function ActOnTypeParameterDefault to check that a template-parameter is not used in its own default argument.

Anyway my problem is this test case:

typedef int T;

template <typename T = T> struct X {
    T x;

int main() {
    X<> foo;
    foo.x = 5;

g++-4.3.3 compiles this without a hitch, but clang fails with: error: incompatible type assigning 'int', expected 'type-parameter-0-0'
        foo.x = 5;

and if I remove foo.x = 5;, clang crashes with clang: ASTContext.cpp:593: std::pair<long unsigned int, unsigned int> clang::ASTContext::getTypeInfo(const clang::Type*): Assertion `false && "Should not see dependent types"' failed.

In other words g++ thinks that the default argument to the template-parameter is the typedef and clang thinks it is the template-parameter itself. I'm not sure which is the right interpretation, but I'm guessing that g++ is correct here.

Should I file a bug report with this test case? Also, I would like to know whether it is reasonable that I continue working on implementing the check on the default argument. If not I'll try to find something easier to work on.

Mark Greve