This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/42819] [C++0x] std::async fails to compile with simple tests, including N3000 example
- From: "lloyd at randombit dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jan 2010 15:38:10 -0000
- Subject: [Bug libstdc++/42819] [C++0x] std::async fails to compile with simple tests, including N3000 example
- References: <bug-42819-6477@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from lloyd at randombit dot net 2010-01-21 15:38 -------
Jon (and Paolo) - thanks for doing the work!
Is there an easy workaround I can apply locally for this? I tried replacing all
instances of `typename _Fn::result_type` with `typename
result_of<_Fn(_Args...)>::type` in future just to see if I can get things going
for me locally, but then get this error on the N3000 example:
In file included from
/usr/local/gcc-4.5-r156097/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/future.2:38:0,
from n3000.cpp:1:
/usr/local/gcc-4.5-r156097/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/functional:
In instantiation of 'std::result_of<std::launch(work(int)::<lambda()>)>':
/usr/local/gcc-4.5-r156097/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/future.2:1328:41:
instantiated from 'std::future<typename std::result_of<_Functor(_ArgTypes
...)>::type> std::async(_Fn&&, _Args&& ...) [with _Fn = work(int)::<lambda()>,
_Args = {}, typename std::result_of<_Functor(_ArgTypes ...)>::type = int]'
n3000.cpp:17:57: instantiated from here
/usr/local/gcc-4.5-r156097/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/functional:183:9:
error: 'std::declval [with _Tp = std::launch, typename
std::add_rvalue_reference<_Tp>::type = std::launch&&]()' cannot be used as a
function
I'm not sure if I have messed this up (my C++0x-fu is still very weak), or if
functional's result_of needs further changes to support this case - it looks to
be using decltype now (a recent change I think; thanks again!) so I had guessed
this would 'just work', but I had never even heard of declval and looking at
type_traits can't quite grok what it's doing or why this isn't happy. Simple
test cases I've tried using result_of on global functions and lambdas seem to
work so I'm having a hard time narrowing it down. Thus this comment. :)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42819