Why is char** (or any T**) to void** cast invalid?

前端 未结 3 1357
小蘑菇
小蘑菇 2021-01-19 16:21

In the first comment to Python C Module - Malloc fails in specific version of Python, @user694733 mentions that casting char** to void** is not val

3条回答
  •  旧时难觅i
    2021-01-19 17:19

    The biggest practical problem is with multiple inheritance. When you use a pointer to a class with multiple base classes, the actual value of the pointer will depend on the type of the pointer, and the compiler inserts fix-up code to adjust it when you assign from one pointer type to another. When you have a pointer to the pointer, the compiler no longer has the opportunity to do those fixups, so the operation is disallowed by the standard.

提交回复
热议问题