http://llvm.org/bugs/show_bug.cgi?id=22625

            Bug ID: 22625
           Summary: Dangling StringRef in clang/lib/Driver/ToolChains.cpp
           Product: clang
           Version: trunk
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Created attachment 13898
  --> http://llvm.org/bugs/attachment.cgi?id=13898&action=edit
Avoid constructing a temporary std::string

In Linux::AddClangSystemIncludeArgs:

  std::string SysRoot = computeSysRoot();
  // ...
      StringRef Prefix = llvm::sys::path::is_absolute(dir) ? SysRoot : "";

The conditional operator produces a std::string rvalue (either a copy of
SysRoot or constructed from the string literal) and so the StringRef is left
dangling.

This breaks clang bootstrap when using the new non-COW std::string in GCC5 (I'm
curious why it doesn't show up with the non-COW string in libc++).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to