Bug in concurrent_vector documentation

Bug in concurrent_vector documentation

Section 5.2 of the Tutorial (Open Source).pdf on the website contains the following code snippet.

void Append( concurrent_vector& vector, const char* string ) {
size_t n = strlen(string)+1;
memcpy( &vector[vector.grow_by(n)], string, n+1 );
}

Isn't this copying the null terminated string plus an additional byte to the vector?
2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Thanks for catching and reporting the error! Though it looks like someone has already fixed it by rewriting the memcpy line in the following way

std::copy( string, string+n, vector.begin()+vector.grow_by(n) );

Not sure if this version has already been released, but at least it is what I see in our mainline at the moment. Anyway, thanks again, and don't hesitate posting other errors you may find (you evidently have a sharp eye), there is a good chance that they are still lying about nonfixed.

Leave a Comment

Please sign in to add a comment. Not a member? Join today