<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/131708>131708</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] no viable conversion from '_Bind_front_t<int (&)(int), int>' (aka '_Bind_front<int (*)(int), int>') to 'std::function<int ()>'
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          vient
      </td>
    </tr>
</table>

<pre>
    Clang 20.1.0, GCC 14.2
```cpp
#include <functional> 
                                                       
int f(int x) { 
    return x; 
}

int main() { 
  std::function<int()> fn = std::bind_front(f, 0);     
  return fn(); 
}
```
results in
```
<source>:8:24: error: no viable conversion from '_Bind_front_t<int (&)(int), int>' (aka '_Bind_front<int (*)(int), int>') to 'std::function<int ()>'
    8 |   std::function<int()> fn = std::bind_front(f, 0);     
 |                        ^ ~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-14.2.0/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0/bits/std_function.h:375:7: note: candidate constructor not viable: no known conversion from '_Bind_front_t<int (&)(int), int>' (aka '_Bind_front<int (*)(int), int>') to 'nullptr_t' (aka 'std::nullptr_t') for 1st argument
  375 | function(nullptr_t) noexcept
      |       ^ ~~~~~~~~~
/opt/compiler-explorer/gcc-14.2.0/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0/bits/std_function.h:386:7: note: candidate constructor not viable: no known conversion from '_Bind_front_t<int (&)(int), int>' (aka '_Bind_front<int (*)(int), int>') to 'const function<int ()> &' for 1st argument
  386 |       function(const function& __x)
      |       ^ ~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-14.2.0/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0/bits/std_function.h:404:7: note: candidate constructor not viable: no known conversion from '_Bind_front_t<int (&)(int), int>' (aka '_Bind_front<int (*)(int), int>') to 'function<int ()> &&' for 1st argument
  404 |       function(function&& __x) noexcept
      |       ^ ~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-14.2.0/lib/gcc/x86_64-linux-gnu/14.2.0/../../../../include/c++/14.2.0/bits/std_function.h:435:2: note: candidate template ignored: requirement '_Callable<std::_Bind_front<int (*)(int), int>, std::_Bind_front<int (*)(int), int>, std::__invoke_result<std::_Bind_front<int (*)(int), int> &>>::value' was not satisfied [with _Functor = _Bind_front_t<int (&)(int), int>]
  435 | function(_Functor&& __f)
      |         ^
1 error generated.
```
Clang 19 does not produce this error. Clang 20 with GCC 15 also does not produce this error, so it is specific to Clang 20 + GCC 14.

https://godbolt.org/z/1Msv6fo9M
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcV8FyozgTfpr2RWUKWmDgwAGT-D_NM1AChK0_ssRKwvHuYZ99SyJ2nEw8uzO1WzUZFwUy6q9p9fepaZi1Yq84ryDbQvawYrM7aFOdBFdu1enh96qRTO0JxlESxYAN-V_TkCSNEOIaNvFy9NPk_yIVqpfzwAnQZpxV74RWTAJ9JBDX5Md-ENdCOTICFv56BiwJ5NuLR8PdbBQ5Aw23IH_w5wVzZEIBFm8Q1g1Aa6D1JT6gjVBuMfORjooAfXi164Qa2tHoYDP6DMTBcnuJ7hrDqC5ebkO55Aji2nA7S2eJUO8mgDZWz6bnQB-B1gXQGlOgNeHGaOMHSpOTYJ3kpNfqxI0VWpHR6CMBzNvtNcbWLeshIZSNjybkLQwa4kf0ETD38-yJvUPfYuu7WJ9Ppz30TjLJNZveeuGpIJA35D_J_-L4Y_Fkj-TPj35Brjs9OcBdr4-TkNys-XmS2nADuNv3_dqr3Gt-J0W33ALcnYtNu0nXUqj5vN6rGXB3tYuir08vO8I_BnAbjldAJ5wF3Fk3tJd0RAegNc0zoHW-EO-4v_ZMDWJgLgjAOjP3Ths_-6KLF5E8Kf2sfiqNqFn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