Issue 131708
Summary [clang] no viable conversion from '_Bind_front_t<int (&)(int), int>' (aka '_Bind_front<int (*)(int), int>') to 'std::function<int ()>'
Labels clang
Assignees
Reporter vient
    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
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to