Is self-initialization 'A a = a;' allowed?

前端 未结 4 657
半阙折子戏
半阙折子戏 2020-12-01 21:46

This code fails at runtime in the copy constructor.
But the compiler (MSVS2008) issues no warnings.

Could you explain (preferably cite the standard) whether this

4条回答
  •  星月不相逢
    2020-12-01 22:36

    Your code is not calling the standard constructor but the copy constructor, so you are accessing an uninitialized pointer.

提交回复
热议问题