This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/53872] New: [C++11] ADL bug in std::thread
- From: "frankhb1989 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 06 Jul 2012 12:12:52 +0000
- Subject: [Bug libstdc++/53872] New: [C++11] ADL bug in std::thread
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53872
Bug #: 53872
Summary: [C++11] ADL bug in std::thread
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: frankhb1989@gmail.com
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.