Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

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?
0 Kudos
1 Reply
New Contributor III
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 nonfixedsmiley [:-)].