[LLVMbugs] [Bug 22625] New: Dangling StringRef in clang/lib/Driver/ToolChains.cpp

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 18 10:30:06 PST 2015


            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: unassignedclangbugs at nondot.org
          Reporter: zilla at kayari.org
                CC: llvmbugs at cs.uiuc.edu
    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

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150218/08d7d4b2/attachment.html>

More information about the llvm-bugs mailing list