Index: llvm/tools/lto/lto.cpp =================================================================== --- llvm/tools/lto/lto.cpp +++ llvm/tools/lto/lto.cpp @@ -474,11 +474,16 @@ } void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) { - std::vector Options; + // Make a copy of the options, so we can nul-terminate them each individual + // one. + std::vector Storage; for (std::pair o = getToken(opt); !o.first.empty(); o = getToken(o.second)) - Options.push_back(o.first.data()); + Storage.push_back(o.first.str()); + std::vector Options; + transform(Storage, back_inserter(Options), + [](const std::string &S) { return S.c_str(); }); unwrap(cg)->setCodeGenDebugOptions(Options); }