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

            Bug ID: 15911
           Summary: User defined constructor lookup fails on local class
                    defined inside template difinition and passed to
                    another template as an template argument
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Clang fails to lookup user defined constructor of local class which is defined
inside the template definition and passed to class template, or function
template by explicit template argument specification.

For class template:

template < typename T >
struct S
{
    T t ;
    S() : t(0) { } } ;
} ;

// local class defined inside template definition.
template < typename T >
void f()
{
    struct local { local( int ) { } } ;

    S<local> s ;
}

// local class defined inside non-template definition.
void g()
{
    struct local { local( int ) { } } ;

    S<local> s ;
}


int main()
{
    f<void>() ; // error: no matching constructor for initialization of 'local'
    g() ; // OK, lookup works
}

Expected behavior: constructor lookup success.
Actual behavior: lookup fails.

For function template, only the explicit template argument specification cause
this problem:

template < typename T >
void f( )
{
    T x(0) ;
}

template < typename T >
void call_f_template()
{
    struct local { local(int) {} } ;
    f<local>() ;
}

void call_f()
{
    struct local { local(int) {} } ;
    f<local>() ;
}


int main()
{
    call_f_template<void>() ; // error: no matching constructor for
initialization of 'local' 
    call_f() ; // OK, lookup works.
}

Interestingly, argument deduction can workaround this problem.
In a context where argument deduction works, explicit template argument
specification also works.

template < typename T >
void f( T const & )
{
    T x(0) ;
}

template < typename T >
void call_f_template()
{
    struct local { local(int) {} } ;
    local obj(0) ;
    f( obj ) ; // OK
    f<local>( obj ) ; // Also OK
}

int main()
{
    call_f_template<void>() ;
}


Only the lookup of user defined constructor fails.
Lookup of implicitly defined constructors works as expected.

-- 
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