2011-12-07 11 views
6

私はubuntu 10.04にclang + llvm 3.0をコンパイルしてインストールしました。また、svnからlibC++をインストールしました。 libC++の状態がスレッドサポートが完了していることを示すので、私はstd :: asyncを試したかったのです。だから私はstd :: async in clang 3.0 + libC++は動作しませんか?

http://www.justsoftwaresolutions.co.uk/threading/multithreading-in-c++0x-part-8-futures-and-promises.html

にアンソニー・ウィリアムズによって与えられた例に従うと、ちょうどそれをコンパイルするためにマイナーな変更を行います。

#include <future> 
#include <iostream> 

int calculate_the_answer_to_LtUaE() 
{ 
    return 42; 
} 

void do_stuff() 
{ 
    std::cout << "doing stuff" << std::endl; 
} 

int main() 
{ 
    std::future<int> the_answer=std::async(calculate_the_answer_to_LtUaE); 
    do_stuff(); 
    std::cout<<"The answer to life, the universe and everything is " 
    <<the_answer.get()<<std::endl; 
} 

を私はコンパイル

打ち鳴らす++と--std = C++ 0x -stdlib = libC++ -lpthread async.cpp

ただし、実行されて常にコアダンプで終了します。

もの 人生、宇宙、すべての答えをやっ

は私がコアダンプをチェックし、それは(私はかなりヒントを得ることはありません)このようなスタック

を示し(コアダンプ)中止されます
 
#0 0x00007fd0a1a7ba75 in raise() from /lib/libc.so.6 
#1 0x00007fd0a1a7f5c0 in abort() from /lib/libc.so.6 
#2 0x00007fd0a22a735b in std::exception_ptr::~exception_ptr (this=) at ../src/exception.cpp:130 
#3 0x0000000000404178 in void std::__1::__assoc_state::set_value(int&&)() 
#4 0x00000000004051ae in _ZNSt3__119__async_assoc_stateIiNS_12__async_funcIPFivEJEEEE9__executeEv() 
#5 0x0000000000404e00 in _ZNSt3__114__thread_proxyINS_5tupleIJMNS_19__async_assoc_stateIiNS_12__async_funcIPFivEJEEEEEFvvEPS7_EEEEEPvSC_() 
#6 0x00007fd0a250f9ca in start_thread() from /lib/libpthread.so.0 
#7 0x00007fd0a1b2e70d in clone() from /lib/libc.so.6 
#8 0x0000000000000000 in ??() 

誰もがなぜアイデアを持っていますか? moshbearさんのコメントで示唆したように、私が見

doing stuff 
The answer to life, the universe and everything is 42 

のlibC++のソースを検査:

clang++ -std=c++0x -stdlib=libc++ async.cpp 

とプログラムの出力を:

+2

アボートとは、アサーションが失敗したことを意味します。 exception.cppのassert()を130行目の近くに置いてください.gdbを使用して地元の人をアボートして分析することを強くお勧めします。 – moshbear

答えて

7

は、私が使用して、OS Xのライオンにあなたの例を走りました
exception_ptr::~exception_ptr() _NOEXCEPT 
{ 
#if HAVE_DEPENDENT_EH_ABI 
    __cxa_decrement_exception_refcount(__ptr_); 
#else 
    #warning exception_ptr not yet implemented 
    ::abort(); 
#endif // __APPLE__ 
} 

~exception_ptr()はubuntu 10.04に移植されていません。これは移植可能なC++では実装できない低レベルの機能です。このレベルのGPLフリー実装の作成作業は、libc++abiで進行中です。私はlibC++ abiが今のところプライムタイムの準備ができていないことを保証します。

この低レベルライブラリでは、https://github.com/pathscale/libcxxrtという独立した取り組みも行われています。私はこのライブラリの状態や、それがubuntuに移植されているかどうかはわかりません。

関連する問題