[LLVMdev] is the SmallVector implementation standard c++?

me22 me22.ca at gmail.com
Thu Aug 28 16:11:40 PDT 2008


On Thu, Aug 28, 2008 at 18:32, Julio <julio.martin.hidalgo at gmail.com> wrote:
> Hi, in simple-inheritance the base object is always allocated first, and
> because of the union of double, long long, etc... the first element is
> aligned, so the others will be contigous. It's a bit tricky but should work
> always...
>

Alignment is probably correct, but since access to the memory is
through a T* but the memory is declared as a char (in GCC) or a union
(elsewhere), I suspect it's technically in violation of the strict
aliasing rules.

Since the SmallVectorImpl constructor sets the 3 pointers, it should
be possible to pass in the begin pointer as well as the size, and
remove the hacks.

Also, the comment the says "Default ctor - Initialize to empty."
should probably be changed, since it's not a default constructor.

Basing all this off a quick peek at
http://llvm.cs.uiuc.edu/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?revision=55181&view=markup
,
~ Scott



More information about the llvm-dev mailing list