Warning: defaulted move assignment operator of X will move assign virtual base class Y multiple times

前端 未结 2 1638
旧巷少年郎
旧巷少年郎 2021-02-06 15:51

I\'m catching a warning under Clang when testing a library under C++11. I\'ve never come across the warning before and searching is not providing too much in the way of reading

2条回答
  •  抹茶落季
    2021-02-06 16:33

    The standard allows implementations to choose a simple but sometimes broken way to handle memberwise assignment in the presence of virtual bases.

    http://en.cppreference.com/w/cpp/language/move_assignment:

    As with copy assignment, it is unspecified whether virtual base class subobjects that are accessible through more than one path in the inheritance lattice, are assigned more than once by the implicitly-defined move assignment operator.

    This is particularly nasty for move assignment, since it may mean assigning from an already moved-from member.

提交回复
热议问题