Open Quuxplusone opened 11 years ago
I have looked at what libc++ does and it (if out of space) allocates a new
vector buffer, copies the element and then deletes the old buffer so we should
do the same in small vector.
if (enough_space)
copy element
else
allocate new buffer
copy element
delete old buffer
this way smallvector.push_back(smallvector[x]) would be safe.
It looks like http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130401/170255.html is related and waiting to be reviewed.
I have started to work on a patch to address these pitfalls https://reviews.llvm.org/D87326
See 183465 and r183459 for an issue that arose because of this (& please revert that fix once this issue is addressed)
r178319 discusses a similar issue with vector wehre Howard Hinnant decreed that it was conforming & didn't add overhead to the vector implementation to do so - so we should do the same thing with SmallVector to avoid surprise