我执行这个简单的代码,但在"WriteBitcodeToFile"祝福异常:"terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc"
我不明白为什么会发生( . 现在我使用llvm 3.6.1,我使用clang 3.6.1 . 在llvm 3.3代码工作正常 .

调用堆栈:

0 raise /lib/x86_64-linux-gnu/libc.so.6 0 0x7ffff6da10d5 1 abort /lib/x86_64-linux-gnu/libc.so.6 0 0x7ffff6da483b 2 __gnu_cxx :: __ verbose_terminate_handler()/ usr / lib / x86_64 -linux-gnu / libstdc .so.6 0 0x7ffff76cbd4d 3 ?? / usr / lib / x86_64-linux-gnu / libstdc .so.6 0 0x7ffff76c9d96 4 std :: terminate()/ usr / lib / x86_64-linux-gnu / libstdc .so.6 0 0x7ffff76c9de1 5 __cxa_throw / usr / lib / x86_64-linux-gnu / libstdc .so.6 0 0x7ffff76c9ff8 6 operator new(unsigned long)/ usr / lib / x86_64-linux-gnu / libstdc .so.6 0 0x7ffff76ca4fc 7 std :: string :: _ Rep :: _ S_create( unsigned long,unsigned long,std :: allocator const&)/ usr / lib / x86_64-linux-gnu / libstdc .so.6 0 0x7ffff7709659 8 std :: string :: _ Rep :: _ M_clone(std :: allocator const&,unsigned long )/ usr / lib / x86_64-linux-gnu / libstdc .so.6 0 0x7ffff770a3fb 9 std :: basic_string,std :: allocator :: basic_string(std :: string const&)/ usr / lib / x86_64-linux-gnu / libstdc .so.6 0 0x7ffff770aadc 10 llvm :: Twine :: str()const Twine.cpp 19 0x6e43c3 11 llvm :: Triple :: Triple(llvm :: Twine const&)Triple.cpp 449 0x6dec99 12 llvm :: WriteBitcodeToFile(llvm ::模块const *,llvm :: raw_ostream&)BitcodeWriter.cpp 2071 0x42eee5 13 main main.cpp 43 0x40da26

码:

std::error_code err_code;
llvm::LLVMContext &ctx = llvm::getGlobalContext();
llvm::Module *mod;
llvm::SMDiagnostic Err;


std::string filename = InputFilename;

mod = llvm::parseIRFile(filename,Err,ctx).get();

llvm::StringRef sRefName(OutputFilename);
llvm::raw_fd_ostream raw(sRefName, err_code,  (llvm::sys::fs::OpenFlags)8);
 llvm::WriteBitcodeToFile(mod, raw); // SIGABORT