[LLVMbugs] [Bug 3946] New: SmallVector::insert should use copy_backward
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sun Apr 5 15:11:49 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=3946
Summary: SmallVector::insert should use copy_backward
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Core LLVM classes
AssignedTo: unassignedbugs at nondot.org
ReportedBy: johnson.peter at gmail.com
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=2791)
--> (http://llvm.org/bugs/attachment.cgi?id=2791)
Testcase demonstrating the issue
SmallVector::insert() (for multiple elements) uses std::copy to copy the
elements that get replaced:
// Copy the existing elements that get replaced.
std::copy(I, OldEnd-NumToInsert, I+NumToInsert);
Unfortunately, I+NumToInsert can easily be within the (I, OldEnd-NumToInsert)
range. Using std::copy_backward() fixes the problem:
// Copy the existing elements that get replaced.
std::copy_backward(I, OldEnd-NumToInsert, OldEnd);
We don't need to decide at runtime between these versions as OldEnd is always
after OldEnd-NumToInsert.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list