Do I really have to worry about alignment when using placement new operator?

后端 未结 5 1712
南笙
南笙 2020-12-05 00:43

I read this When should I worry about alignment? but I am still do not know if I have to worry about not aligned pointer returned by placement new operator - like in this e

5条回答
  •  渐次进展
    2020-12-05 01:21

    Yes, it all depends on the architecture, and probably the compiler optimization flags as well. It will all work fine until you do A b = a; or some other random access which gets compiled to some movdqa ops and your program crashes.

提交回复
热议问题