Here is the example for std::async included in the N3000 draft (section
30.6.9):

#include <future>

int work1(int value);
int work2(int value);

int work(int value)
   {
   auto handle = std::async([=] { return work2(value); });
   int tmp = work1(value);
   return tmp + handle.get();
   }

With svn r156097, it fails to compile:

$ g++-4.5-r156097 -std=c++0x -c n3000.cpp 
n3000.cpp: In function 'int work(int)':
n3000.cpp:8:57: error: no matching function for call to
'async(work(int)::<lambda()>)'
n3000.cpp:8:57: error: unable to deduce 'auto' from '<expression error>'

It also fails with `auto handle = std::async(work2, value);`

$ g++-4.5-r156097 -v
Using built-in specs.
COLLECT_GCC=g++-4.5-r156097
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.5-r156097/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-svn/configure --enable-languages=c,c++
--prefix=/usr/local/gcc-4.5-r156097 --program-suffix=-4.5-r156097
Thread model: posix
gcc version 4.5.0 20100120 (experimental) (GCC)


-- 
           Summary: [C++0x] std::async fails to compile with simple tests,
                    including N3000 example
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lloyd at randombit dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42819

Reply via email to