Open edfvogel opened 1 year ago
@llvm/issue-subscribers-clang-frontend
Oh...I note that Microsoft Visual Studio (2019) gives a similar error. So maybe it's more likely that this is a g++ extension.
This was noticed by someone that was upgrading to C++11. Their program was calling the C function bind(). They had included
libstdc++ seems to explicitly disable std::bind
if the first argument is an integral or enumeration type:
Which libc++ does not have: https://github.com/llvm/llvm-project/blob/main/libcxx/include/__functional/bind.h#L366
This can be supported in libc++ with:
template<class _Fp, class ..._BoundArgs, class = typename enable_if<!is_integral<typename decay<_Fp>::type>::value && !is_enum<typename decay<_Fp>::type>::value>::type>
But this would be non-standard (it would break valid code that looks like:
static_assert(requires{ std::bind(1); });
but I would think the benefits outweigh this edge case)
std::bind(1)
is UB anyway because of [func.bind.bind]/3.
The following (very contrived) program shows a program that is accepted when the g++ headers are used, but not when the libc++ headers are used.
Not sure if this is a bug in libc++, but it can pose a porting issue. Any comments are welcome.
Thanks so much,
Ed Vogel
Here is the reproducer from a cygwin session:
Note that if there is no assignment of the return value, the program compiles.