<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - User defined constructor lookup fails on local class defined inside template difinition and passed to another template as an template argument"
   href="http://llvm.org/bugs/show_bug.cgi?id=15911">15911</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>User defined constructor lookup fails on local class defined inside template difinition and passed to another template as an template argument
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>boostcpp@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>