mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-10 12:59:21 +03:00
Fixed a bug regarding lifetime of C strings.
The string returned by c_str() is only valid as long as the object exists. Now the object 'triple' exists until the end.
This commit is contained in:
parent
7c7a9e564a
commit
af69672dc7
1 changed files with 5 additions and 3 deletions
|
@ -477,6 +477,8 @@ int main(int argc, char** argv)
|
|||
#endif
|
||||
}
|
||||
|
||||
std::string triple;
|
||||
|
||||
// did the user override the target triple?
|
||||
if (mTargetTriple.empty())
|
||||
{
|
||||
|
@ -485,14 +487,14 @@ int main(int argc, char** argv)
|
|||
error("you must specify a target triple as well with -mtriple when using the -march option");
|
||||
fatal();
|
||||
}
|
||||
global.params.targetTriple = defaultTriple.c_str();
|
||||
triple = defaultTriple;
|
||||
}
|
||||
else
|
||||
{
|
||||
global.params.targetTriple = llvm::Triple::normalize(mTargetTriple).c_str();
|
||||
triple = llvm::Triple::normalize(mTargetTriple);
|
||||
}
|
||||
|
||||
std::string triple = global.params.targetTriple;
|
||||
global.params.targetTriple = triple.c_str();
|
||||
|
||||
// Allocate target machine.
|
||||
const llvm::Target *theTarget = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue