<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - template lambda with default value can't be called if passing argument type doesn't match default value type"
   href="https://bugs.llvm.org/show_bug.cgi?id=46648">46648</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>template lambda with default value can't be called if passing argument type doesn't match default value type
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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++2a
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>iurii.shtykov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>interactive: <a href="https://godbolt.org/z/mM9hY8">https://godbolt.org/z/mM9hY8</a>

code: 
_________________________
#include <string>

using std::literals::operator""s;
int main(){
    auto error_lambda = []<class T = int>(T def = 1) -> T {
        return def;
    };

    error_lambda(1);
    error_lambda("error"s);

    //but it works if default value = 0
    auto good_lambda = []<class T = int>(T def = 0) -> T {
        return def;
    };

    good_lambda(1);
    good_lambda("good"s);
}
_________________________

output:

<source>:10:5: error: no matching function for call to object of type '(lambda
at <source>:5:25)'
    error_lambda("error"s);
    ^~~~~~~~~~~~
<source>:5:25: note: candidate template ignored: substitution failure [with T =
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>>]: no viable conversion from 'int' to
'std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>>'
    auto error_lambda = []<class T = int>(T def = 1) -> T {
                        ^                   ~~~
1 error generated.
Compiler returned: 1</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>