D:\Temp2>type repro.cpp
#include <functional>
#include <iostream>
int main() {
auto l = [](int) {};
auto f = std::bind(l, std::placeholders::_1);
std::cout << std::is_convertible<decltype(f), std::function<void()>>::value << std::endl;
}
D:\Temp2>cl /EHsc /W4 /WX .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29009.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
repro.cpp
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\utility(487): error C2338: tuple index out of bounds
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\functional(1371): note: see reference to class template instantiation 'std::tuple_element<0,std::tuple<>>' being compiled
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\tuple(672): note: see reference to alias template instantiation 'std::tuple_element_t<0,std::tuple<>>' being compiled
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\tuple(790): note: see reference to function template instantiation 'const tuple_element<_Index,std::tuple<_Rest...>>::type &&std::get(const std::tuple<_Rest...> &&) noexcept' being compiled
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\type_traits(1720): note: see reference to alias template instantiation 'std::_Decltype_invoke_zero<std::_Binder<std::_Unforced,main::<lambda_47bb48da0a3b46550689dee1f28f59ab> &,const std::_Ph<1> &>&>' being compiled
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\type_traits(1796): note: see reference to alias template instantiation 'std::_Is_invocable_r_<void,std::_Binder<std::_Unforced,main::<lambda_47bb48da0a3b46550689dee1f28f59ab> &,const std::_Ph<1> &>&,>' being compiled
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\functional(961): note: see reference to class template instantiation 'std::_Is_invocable_r<_Ret,_From &>' being compiled
with
[
_Ret=void,
_From=std::_Binder<std::_Unforced,main::<lambda_47bb48da0a3b46550689dee1f28f59ab> &,const std::_Ph<1> &>
]
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\functional(961): note: see reference to variable template 'const bool conjunction_v<std::negation<std::is_same<std::_Binder<std::_Unforced,<lambda_47bb48da0a3b46550689dee1f28f59ab> &,std::_Ph<1> const &>,std::function<void __cdecl(void)> > >,std::_Is_invocable_r<void,std::_Binder<std::_Unforced,<lambda_47bb48da0a3b46550689dee1f28f59ab> &,std::_Ph<1> const &> &> >' being compiled
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\utility(487): note: see reference to alias template instantiation 'std::_Func_class<_Ret>::_Enable_if_callable_t<_From&,std::function<void (void)>>' being compiled
with
[
_Ret=void,
_From=std::_Binder<std::_Unforced,main::<lambda_47bb48da0a3b46550689dee1f28f59ab> &,const std::_Ph<1> &>
]
.\repro.cpp(7): note: see reference to class template instantiation 'std::is_convertible<std::_Binder<std::_Unforced,main::<lambda_47bb48da0a3b46550689dee1f28f59ab> &,const std::_Ph<1> &>,std::function<void (void)>>' being compiled
Microsoft Visual Studio Professional 2019 Preview
Version 16.7.0 Preview 3.1
Describe the bug
std::is_convertiblefails to compile broken for a lambda passed tostd::bindCommand-line test case
Expected behavior
The program should compile.
(It should print zero, as the types are not expected to be convertible)
STL version
Additional context
This item is also tracked on Developer Community as DevCom-317991 and by Microsoft-internal VSO-671111 / AB#671111.