[LLVMbugs] [Bug 3860] New: SmallVector::insert(iterator I, InTy From, InTy To) is broken

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Mar 22 05:14:22 PDT 2009


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

           Summary: SmallVector::insert(iterator I, InTy From, InTy To) is
                    broken
           Product: libraries
           Version: 2.5
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Support Libraries
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: llvm-bug at catchall.shelter13.net
                CC: llvmbugs at cs.uiuc.edu


SmallVector insert triggers a debug validation failure with MSVC++, because it
passes an invalid range to std::copy. Specifially,

// Copy the existing elements that get replaced.
std::copy(I, OldEnd-NumToInsert, I+NumToInsert);

in

template<typename ItTy>
iterator insert(iterator I, ItTy From, ItTy To)

passes an I > (OldEnd-NumToInsert) to std::copy, which would result in memory
corruption at best.

Simple test case to trigger it.
const char * t = "Cannot load string";
//                01234567890123456789
const char * other = ">> \n";
//                    012345
SmallVector<char, 16> test (t, t + 18);
SmallVector<char, 16>::iterator it = test.end ();
--it;

test.insert (it, other, other + 4);

Actually, any insert at begin () + N, with N 3..17 fails in that case,
including at the end.


-- 
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