开发者

Overlapping source and destination blocks in memcpy with boost

Can anyone explain me why on that c++ simple code valgrind returns this.

First problem is with boost:regex. When i use subpattern with a question mark (for optional matching) valgrind will return:

Source an开发者_开发知识库d destination overlap in memcpy (line 8)

Second problem is with std::string::erase.

I have no idea what am i doing wrong.


Seems like the library code is using memcpy when, to be strictly portable, it should be using memmove.

For the compiler's library, like std::string, this is probably ok as that code doesn't have to be portable to other compilers, and can use knowledge about how the specific implementation works.

With the boost library, you will probably have to trust that they also know what they are doing. The library has a lot of configurations for different compilers and might also use a specific g++ extension.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜