Code below fails to compile using mingw-g++4.7.1 from sourceforge.net/projects/mingwbuilds: #include <thread> #include <memory> #include <functional> template<typename, typename...P> void make_shared(P&&...) {} struct C{}; // enable ADL void f(C){} int main() { std::thread t(std::bind(&::f, C())); //error } Messages: d:\mingw\bin\..\lib\gcc\i686-w64-mingw32\4.7.1\include\c++\thread||In instantiation of 'std::shared_ptr<std::thread::_Impl<_Callable> > std::thread::_M_make_routine(_Callable&&) [with _Callable = std::_Bind_simple<std::_Bind<void (*(C))(C)>()>]':| d:\mingw\bin\..\lib\gcc\i686-w64-mingw32\4.7.1\include\c++\thread|133|required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = std::_Bind<void (*(C))(C)>; _Args = {}]'| F:\Programing\Temp\T9.cpp|31|required from here| d:\mingw\bin\..\lib\gcc\i686-w64-mingw32\4.7.1\include\c++\thread|191|sorry, unimplemented: use of 'type_pack_expansion' in template| d:\mingw\bin\..\lib\gcc\i686-w64-mingw32\4.7.1\include\c++\thread|191|sorry, unimplemented: use of 'type_pack_expansion' in template| d:\mingw\bin\..\lib\gcc\i686-w64-mingw32\4.7.1\include\c++\thread|191|error: call of overloaded 'make_shared(std::_Bind_simple<std::_Bind<void (*(C))(C)>()>)' is ambiguous| d:\mingw\bin\..\lib\gcc\i686-w64-mingw32\4.7.1\include\c++\thread|191|note: candidates are:| d:\mingw\bin\..\lib\gcc\i686-w64-mingw32\4.7.1\include\c++\bits\shared_ptr.h|611|note: std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = std::thread::_Impl<std::_Bind_simple<std::_Bind<void (*(C))(C)>()> >; _Args = {std::_Bind_simple<std::_Bind<void (*(C))(C)>()>}]| F:\Programing\Temp\T9.cpp|22|note: void make_shared(P&& ...) [with <template-parameter-1-1> = std::thread::_Impl<std::_Bind_simple<std::_Bind<void (*(C))(C)>()> >; P = {std::_Bind_simple<std::_Bind<void (*(C))(C)>()>}]| The line 191 of <thread>(in member template _M_make_routine): return make_shared<_Impl<_Callable>>(std::forward<_Callable>(__f)); After I adding "std::" before "make_shared", it works fine. Note: there is something wrong with the error message("unimplemented"). I'd file another bug for it.
Mine.
Author: paolo Date: Fri Jul 6 13:55:58 2012 New Revision: 189329 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189329 Log: 2012-07-06 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/53872 * include/std/thread (thread::_M_make_routine): Qualify make_shared to prevent ADL. * testsuite/30_threads/thread/adl.cc: New. Added: trunk/libstdc++-v3/testsuite/30_threads/thread/adl.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/std/thread
Author: paolo Date: Fri Jul 6 13:56:24 2012 New Revision: 189330 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189330 Log: 2012-07-06 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/53872 * include/std/thread (thread::_M_make_routine): Qualify make_shared to prevent ADL. * testsuite/30_threads/thread/adl.cc: New. Added: branches/gcc-4_7-branch/libstdc++-v3/testsuite/30_threads/thread/adl.cc Modified: branches/gcc-4_7-branch/libstdc++-v3/ChangeLog branches/gcc-4_7-branch/libstdc++-v3/include/std/thread
Fixed mainline and 4.7.2.
The new test fails on older Solaris 8 versions: Running target unix FAIL: 30_threads/thread/adl.cc (test for excess errors) I think you need to add: // { dg-require-cstdint "" } // { dg-require-gthreads "" } like in the other tests, e.g id/hash.cc and id/operators.cc.
Oops, I'll fix it momentarily, thanks!