On Sun, Aug 26, 2012 at 7:00 AM, Jonathan Wakely <jwakely....@gmail.com> wrote: > On 26 August 2012 00:02, Jonathan Wakely wrote: >> This fixes a stupid mistake I made where the functor and asynchronous >> result can go out of scope before the async thread is joined. >> >> The _Async_state_common destructor still needs to be exported from the >> library, which is what the macro hack is for. >> >> PR libstdc++/54297 >> * include/std/future (~_Async_state_impl): Join thread before >> derived class members are destroyed. >> (~_Async_state_common): Only define non-trivial destructor when >> included from future.cc for ABI compatibility reasons. >> * src/c++11/future.cc (_GLIBCXX_ABI_COMPAT_ASYNC): Define. >> * testsuite/30_threads/async/54297.cc: New. >> >> Tested x86_64-linux, committed to trunk and 4.7 > > I realised the compatibility symbols should be in one of the files > used for that purpose, so this moves them to > src/c++11/compatibility-thread-c++0x.cc > > PR libstdc++/54297 > * src/c++11/future.cc (~_Async_state_common): Move to... > * src/c++11/compatibility-thread-c++0x.cc (~_Async_state_common): > Here. > (_GLIBCXX_ABI_COMPAT_ASYNC): Rename to _GLIBCXX_ASYNC_ABI_COMPAT. > * include/std/future (_GLIBCXX_ABI_COMPAT_ASYNC): Likewise. > > Tested x86_64-linux, committed to trunk and 4.7
Does it fix: output is: /export/gnu/import/git/gcc/libstdc++-v3/testsuite/30_threads/async/54297.cc: In member function 'void Task::operator()() const':^M /export/gnu/import/git/gcc/libstdc++-v3/testsuite/30_threads/async/54297.cc:42:5: error: 'sleep_for' is not a member of 'std::this_thread'^M std::this_thread::sleep_for(std::chrono::seconds(1));^M ^^M FAIL: 30_threads/async/54297.cc (test for excess errors) Excess errors: /export/gnu/import/git/gcc/libstdc++-v3/testsuite/30_threads/async/54297.cc:42:5: error: 'sleep_for' is not a member of 'std::this_thread' -- H.J.