1

On GCC 4.7.2 (on cygwin, compiled from source) using std::async fails with

error: invalid use of incomplete type

of some std::__async_sfinae_helper. I am out of luck and appreciate your help.

#include <future>

int main()
{
  std::async([]{});
}

fails with

g++ -Wall -pedantic -std=c++0x    future.cpp   -o future
future.cpp: In function 'int main()':
future.cpp:5:22: error: invalid use of incomplete type 'std::__async_sfinae_helper<main()::<lambda()>, main()::<lambda()> >::type {aka class std::future<void>}'
In file included from future.cpp:1:0:
/usr/local/lib/gcc/i686-pc-cygwin/4.7.2/../../../../include/c++/4.7.2/future:111:11: error: declaration of 'std::__async_sfinae_helper<main()::<lambda()>, main()::<lambda()> >::type {aka class std::future<void>}'
/usr/local/lib/gcc/i686-pc-cygwin/4.7.2/../../../../include/c++/4.7.2/future: At global scope:
/usr/local/lib/gcc/i686-pc-cygwin/4.7.2/../../../../include/c++/4.7.2/future:187:5: error: 'typename std::__async_sfinae_helper<typename std::decay<_Func>::type, _Fn, _Args ...>::type std::async(_Fn&&, _Args&& ...) [with _Fn = main()::<lambda()>; _Args = {}; typename std::__async_sfinae_helper<typename std::decay<_Func>::type, _Fn, _Args ...>::type = std::future<void>]', declared using local type 'main()::<lambda()>', is used but never defined [-fpermissive]
<builtin>: recipe for target `future' failed

Version information

% g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-cygwin/4.7.2/lto-wrapper.exe
Target: i686-pc-cygwin
Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++
Thread model: single
gcc version 4.7.2 (GCC)

c++11 std::async doesn't work in mingw did not help because neither am I using mingw, nor is the thread model win32.

Community
  • 1
  • 1
Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
  • I think it is related to the problem related on mingw question, did you tried to see whether _GLIBCXX_HAS_GTHREADS is defined or not? Here on cygwin and gcc 4.5.3 it is not defined and I got the same error message. Another one related http://stackoverflow.com/questions/7177887/ – coelhudo Jan 04 '13 at 23:07
  • Did you try compiler key `-std=c++11`? – Loom Jan 25 '13 at 18:07
  • Yes, no success, same error. – Micha Wiedenmann Jan 30 '13 at 13:19

0 Answers0