template<typename R> struct future { }; #ifndef NO_PROTO template<typename Fn, typename... Args> auto async(Fn&& fn, Args&&... args) -> future<decltype(fn(args...))>; #endif
template<typename Fn, typename... Args> auto async(Fn&& fn, Args&&... args) -> future<decltype(fn(args...))>; int work2(int value); void work(int value) { auto handle = async(work2, value); } trunk gives this error: $ g++45 -std=c++0x -c -fmessage-length=70 pr42819.min2.cc pr42819.min2.cc: In function 'void work(int)': pr42819.min2.cc:19:34: error: call of overloaded 'async(int (&)(int), int&)' is ambiguous pr42819.min2.cc:6:2: note: candidates are: future<decltype (fn(async::args ...))> async(Fn&&, Args&& ...) [with Fn = int (&)(int), Args = {int&}, decltype (fn(async::args ...)) = int] pr42819.min2.cc:12:2: note: future<decltype (fn(async::args ...))> async(Fn&&, Args&& ...) [with Fn = int (&)(int), Args = {int&}, decltype (fn(async::args ...)) = int] pr42819.min2.cc:19:34: error: unable to deduce 'auto' from '<expression error>' The declarations are identical and the error goes away if you define NO_PROTO. -- Summary: [C++0x] ambiguous overload from identical declarations using decltype Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: redi at gcc dot gnu dot org OtherBugsDependingO 42819 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43054