<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJylVcty2zoM_Rp6g4lGj_i10CK22yw6XTVzZ-6SomCJLUVqSMpO7tdfQJKdpEmbmTYjRSABAgfHAFi5-qn8hgjKdb026AEfe-M8CSLftDH2QRR3Iv9Mz_l8ThpXV87ExPmGdv6j9_7-8Yv79z48inwLlYst3O_3IG0NX7_9Q4JS2McAsUU4OmPcWduGotWYwN5I2yB4_I6KTKonaPSJ1ei98-COZGdP6IN2FozsqlomAHdKOV-zWXQglrsQKZj0tcj3Ynl4gzrqLjjb3Ki-Txod26FKtKN9Wp97-lK-Pum97pIpgsgLZVwYPN5sOaUGLXqt5vgQWjeYGkLUxkCFM8KoK4OM5zhYFRlu77SNxOK51aoFHaDGo7ZYc5bxqUcQq7RGZVgmzCLfUSoT_geIRP72RhSfHsR65zEO3kIkk0wUO7E-MCw6LtKDSO_m_8W-90gnSGByWRoVEbveyEgxVibScY5nZYfwQDsN70x2cmD0zk3xiUv4CN18_NcQiTH6kPoCdDvbjYpNZOUlPB8ZhZPTNUQMcQz76vSIbsqCuL3CzzdLhnsFSDqI09F3cb2NSZxxQcy0jYuZzBcMKy7WrHhToh_wT-vgBq8m3d2G3pze6TwL1kEno2rZ6bV6juRbSaowLvF8PWa-nhzC_Md7xZ6JIMd_zMHFm1h-Euv3nsnKOqogAquo1XRN5fQMlWKeqa3gAURxAMazPLA9nLSkpphT_GHd2b5s56N3HadGYOfOklRXb8nKbhluvp6Z-EVRXvIFbhoGAdfC4ewuHJCHHWSvCmByznznNLKkb4YOKYc_7InfdexP7XClfVxlc0GN04b4rZNpf38Zy5NPrJnP7IOyXdRlUW-LrVxQBq3zpdXqRztQ_W63i8Gb8vWEnKci3QC0MOZ0-dz03vFkpqUOYcBAwrLYFKtFW94WssrSzUZVqsBVnlWyWCu1ksVyI1W1SRdGVmhCyRTlucUzjC5IJsYWf49Al3ma05Mt07TIb7OkONaYrY60laJMaTjepthJbRL2w9fVwpejy2poAimNDjE8K2UIurGI5fSbLqKOBstLZYYXc116mp482Y_kPXBZPt8CNN7fuQMWI_ZyBP4_gGU6mQ>53836</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lambda as function parameter fails to be converted to function pointer
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nickhuang99
</td>
</tr>
</table>
<pre>
See compiler explorer (https://www.godbolt.org/z/GGxKoYGsx) both GCC and MSVC accepts the following code. Clange rejects by giving error of conversion lambda. According to [standard,](https://timsong-cpp.github.io/cppwp/expr.prim.lambda#closure-9) generic lambda should still be convertible to function pointer which is defined by type `decltype(+[](T t )->T{return t+1;}) `
<pre><code>
template<typename T>
auto foo(T t, decltype(+[](T t )->T{return t+1;}) lam){
return lam(t);
}
void test(){
foo<int>(5, [](int t){return t+1;});
}
</code></pre>
clang13 giving error of
<pre><code>
<source>:8:2: error: no matching function for call to 'foo'
foo<int>(5, [](int t){return t+1;});
^~~~~~~~
note: candidate function [with T = int] not viable: no known conversion from '(lambda at <source>:8:14)' to 'decltype(+[](int t) -> int {
return t + 1;
})' for 2nd argument
auto foo(T t, decltype(+[](T t )->T{return t+1;}) lam){
^
1 error generated.
Compiler returned: 1
</code></pre>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVU1zpDgM_TXmogrVQH9x4JDuns1ha0-Tmqo5GtuAd4xN2aY7mV8_EtCdZJPZVE0XNLIlS08PSdROPldflQLh-kEb5UE9DcZ5FFi-72IcAivuWf4XXpfLJW2drJ2JqfMt7vzE--Hh6W_3_SE8sbyE2sUOHo5H4FbCP1-_oSCEGmKA2ClonDHuom2L0aRK4Wi4bRV49a8SaFI_Q6vPpFbeOw-uQTt7Vj5oZ8HwvpY8BbgXwnlJZtEB2xxCxGDcS5Yf2eb0DnXUfXC2vRPDkLY6dmOdaof7uL4M-MR8fTp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