[LLVMdev] [Patch] Fix bug in llvm::SmallVectorIml<>::insert

Johannes Schaub (litb) schaub.johannes at googlemail.com
Sat Mar 19 10:05:03 PDT 2011


This fixes a bug in SmallVectorImpl<>::insert, which were not behaving 
correctly on inserting an empty range into an empty vector:

#include <llvm/ADT/SmallVector.h>
#include <cassert>

int main() {
  llvm::SmallVector<int, 1> v, w;
  llvm::SmallVector<int, 1>::iterator it =
    v.insert(v.end(), w.begin(), w.end());
  assert(it == v.end());
}

The insert function(s) would incorrectly return "this->end()-1". I attached 
the patch which I diff'ed from trunk. Is it important enough to be 
backported to llvm2.9 ?

I would like to ask someone to commit it to wherever it fits. Thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_smallvector.patch
Type: text/x-patch
Size: 906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110319/9943fcd2/attachment.bin>


More information about the llvm-dev mailing list