memcpy vs assignment in C — should be memmove?

前端 未结 3 1309
忘掉有多难
忘掉有多难 2021-01-02 05:13

As pointed out in an answer to this question, the compiler (in this case gcc-4.1.2, yes it\'s old, no I can\'t change it) can replace struct assignments with memcpy where it

3条回答
  •  抹茶落季
    2021-01-02 05:50

    I suppose that there is a typo: "&o" instead of "0". Under this hypothesis, the "overlap" is actually a strict overwrite: memcpy(&o->i,&o->i,sizeof(o->i)). In this particular case memcpy behaves correctly.

提交回复
热议问题