|
From: Vojtech F. <voj...@se...> - 2008-03-28 13:25:10
|
> Vectors are special: I'm not sure "_STLP_USE_NEWALLOC" catches
> vector<> resizing. Consider e.g. the following code:
>
> struct C { int i; };
> int main()
> {
> std::vector<C> V;
> V.resize(2);
> V[1].i = 1;
> V.resize(1);
> V.resize(2);
> printf("V[1].i = %d\n", V[1].i);
> return 0;
> }
>
> Since std::vector<> does not reallocate the vector when resizing it
> from two to one elements, memcheck doesn't complain that the value
> read by the printf() call is undefined.
>
> Bart.
You are right. It is more tricky than I thought.
But if the vector is accessed only from one thread it should not be a problem
for helgrind.
Probably helgrind does not see that the memory the vector occupies is eventually
deleted or STLPort recycles memory even with "new_alloc".
I don't know. I will have to investigate it further.
Vojtech
|