-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed as duplicate of#131708
Closed as duplicate of#131708
Copy link
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"duplicateResolved as duplicateResolved as duplicatelibstdc++GNU libstdc++ C++ standard libraryGNU libstdc++ C++ standard library
Description
Steps to reproduce
Given the following code:
#include <functional>
struct Logger {
void log(int answer) const;
};
int main() {
Logger l;
std::function<void(int)> fn = std::bind_front(&Logger::log, &l);
}
compile with recent clang against libstdc++ 14 headers (depending on the system, that may require adding --gcc-toolchain=/path/to/gcc-14-installation
to the clang command):
$ clang-22 -c -std=c++23 test.cpp
Expected results
Compiles successfully.
This is what happens when compiling with gcc 14, and also when compiling with clang using other libstdc++ versions (at least I tested with 12 and 15 and they work fine).
Actual results
$ clang-22 -c -std=c++23 test.cpp
test.cpp:9:30: error: no viable conversion from '_Bind_front_t<void (Logger::*)(int) const, Logger *>' (aka '_Bind_front<void (Logger::*)(int) const, Logger *>') to
'std::function<void (int)>'
9 | std::function<void(int)> fn = std::bind_front(&Logger::log, &l);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc-14.2/lib/gcc/x86_64-pc-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<void (Logger::*)(int) const, Logger *>' (aka '_Bind_front<void (Logger::*)(int) const, Logger *>') to 'nullptr_t' (aka 'std::nullptr_t') for
1st argument
375 | function(nullptr_t) noexcept
| ^ ~~~~~~~~~
gcc-14.2/lib/gcc/x86_64-pc-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<void (Logger::*)(int) const, Logger *>' (aka '_Bind_front<void (Logger::*)(int) const, Logger *>') to 'const function<void (int)> &' for 1st
argument
386 | function(const function& __x)
| ^ ~~~~~~~~~~~~~~~~~~~
gcc-14.2/lib/gcc/x86_64-pc-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<void (Logger::*)(int) const, Logger *>' (aka '_Bind_front<void (Logger::*)(int) const, Logger *>') to 'function<void (int)> &&' for 1st
argument
404 | function(function&& __x) noexcept
| ^ ~~~~~~~~~~~~~~
gcc-14.2/lib/gcc/x86_64-pc-linux-gnu/14.2.0/../../../../include/c++/14.2.0/bits/std_function.h:435:2: note: candidate template ignored:
requirement 'std::function<void (int)>::_Callable<std::_Bind_front<void (Logger::*)(int) const, Logger *>, std::_Bind_front<void (Logger::*)(int) const, Logger *>,
std::__invoke_result<std::_Bind_front<void (Logger::*)(int) const, Logger *> &, int>>::value' was not satisfied [with _Functor = _Bind_front_t<void (Logger::*)(int) const, Logger *>]
435 | function(_Functor&& __f)
| ^
1 error generated.
(Originally reported at clangd/clangd#2455.)
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"duplicateResolved as duplicateResolved as duplicatelibstdc++GNU libstdc++ C++ standard libraryGNU libstdc++ C++ standard library