<source>:24:12: error: no viable conversion from returned value of type '_Bind_front_t<void (SomeObject::*)() noexcept, SomeObject *&>' (aka '_Bind_front<void (SomeObject::*)() noexcept, SomeObject *>') to function return type 'std::move_only_function<void () noexcept>'
[...]
What is strange to me is that it seems quite inconsistent with which clang versions it fails to compile. Here is a compiler explorer link ( Compiler Explorer ) with the following versions:
compiler explorer x64-64 clang 21.1.0 - ok
compiler explorer x64-64 clang 20.1.0 - error
compiler explorer x64-64 clang 19.1.0 - ok
I also did some tests of my own: (linux runs in docker containers, windows runs on the host)
linux (x86_64-pc-linux-gnu) clang 19.1.7 - ok
linux (x86_64-pc-linux-gnu) clang 20.1.8 - error
linux (x86_64-pc-linux-gnu) clang 21.1.3 - error
windows (x86_64-pc-windows-msvc) clang 21.1.3 - ok
all other versions on windows that I tried worked as well
I also found a another snippet that might be related:
struct SomeObject {
void fn() noexcept;
};
using T = std::invoke_result_t<decltype(std::bind_front(
&SomeObject::fn, std::declval<SomeObject*>()))>;
static_assert(std::is_same_v<T, void>);
Here it seems that std::bind_front isn’t invokable, which can’t be right?
Can you please file this as a Github issue instead? You should add the libc++ tag on the issue since that would be a libc++ issue, not a Clang issue. That is the preferred way of reporting these kinds of issues. Someone should be able to take a look pretty quickly since you have reproducers (which is great, thanks for that).
Since I am actually using libstdc++, I got the suspicion that maybe my own containers (and maybe the ones from compiler explorer too) use an incompatible version.
In our containers, we also install GCC 14, which I suspect brings the libstdc++ library.
Looks like it is indeed a problem with the version of libstdc++ that is installed in the system.
I just built a docker container for clang 21.1.4 using the instructions from About — LLVM 22.0.0git documentation . In there I had to install libstdc++-12-dev (which installed libstdc++ version 12.2.0-14+deb12u1) and then the example programs worked flawlessly.
Working container (built according to docs) with version 21.1.4:
To me this looks like some kind of incompatibility between clang > 19 and libstdc++ 2.39.
For our purposes, we are going to ensure that clang uses the working libstdc++ 2.36 in our containers instead of the newer one from a more recent GCC installation.
The question is, is this still a bug that I should report somewhere or is this expected behavior?
Oh, I hadn’t understood your setup. I initially thought you were using libc++, not libstdc++.
I believe it would make sense to report this to libstdc++, since the issue seems to be that it’s broken with newer Clangs. I’m not certain what their stance is with respect to support Clang so I don’t know whether they will be willing to investigate. However, if they do investigate and it turns out that their code is conforming, then I would expect them to send it back to Clang instead for investigation – it’s usually how I’d expect the bug to flow through library/compiler.