Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7833 Discussions

Compile error when using C++0x std::bind when the system gcc is 4.7.2


When using gcc4.7.2 system headers & -std=c++0x, I get the following compiler error. I believe this is an intel-only issue as building the same source with the gcc4.7.2 compiler works, so I presume it is a problem with how intel interprets the implicit casting. I get the same error on non-gcc47 distros (eg. rhel5) when I use -gxx-name=gcc47 (for me, gcc47 points to a gcc4.7.2 binary for rhel5)

#include <functional>

bool foo(int * x, int y, int z);

int main() { 

    typedef std::function<bool (int * x, int y, int z)> FooHandler;

    using namespace std::placeholders;

    FooHandler m_foo = std::bind(&foo, _1, _2, _3);


Command line & output :

icc13 -c -std=c++0x x.cpp -o x.o

/usr/include/c++/4.7.2/tuple(854): error: no instance of constructor "std::tuple<_Elements...>::tuple [with _Elements=<int *&&, int &&, int &&>]" matches the argument list

argument types are: (int *, int, int)
{ return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
detected during:
instantiation of "std::tuple<_Elements &&...> std::forward_as_tuple(_Elements &&...) [with _Elements=<int *, int, int>]" at line 1214 of "/usr/include/c++/4.7.2/functional"
instantiation of "_Result std::_Bind<_Functor (_Bound_args...)>::operator()(_Args &&...) [with _Functor=bool (*)(int *, int, int), _Bound_args=<std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>>, _Args=<int *, int, int>, _Result=bool]" at line 1912 of "/usr/include/c++/4.7.2/functional"
instantiation of "_Res std::_Function_handler<_Res (_ArgTypes...), _Functor>::_M_invoke(const std::_Any_data &, _ArgTypes...) [with _Res=bool, _Functor=std::_Bind<bool (*(std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(int *, int, int)>, _ArgTypes=<int *, int, int>]" at line 2298 of "/usr/include/c++/4.7.2/functional"
instantiation of "std::function<_Res (_ArgTypes...)>::function(_Functor, std::enable_if<<expression>, std::function<_Res (_ArgTypes...)>::_Useless>::type) [with _Res=bool, _ArgTypes=<int *, int, int>, _Functor=std::_Bind<bool (*(std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(int *, int, int)>]" at line 10 of "x.cpp"

compilation aborted for x.cpp (code 2)

0 Kudos
1 Reply

I can duplicate the issue on Fedora 17 and 19 with gcc 4.7.0. I'll file a bug report for it. Thanks for letting us know.

The icpc 14.0 beta also has the same issue.


0 Kudos