The limitation is not to violate the type system. The first conversion is in order:
type *p = ...; void *vp = p;
As long as you give away this type, you cannot do too much damage to the original value, since there is little to be done with the void object, and all changes in vp are local to the pointer and cannot affect p .
If the second case is allowed:
type **p = ...; void **vp = p;
Then great looking and right code can break your application. For instance:
int *parray[10]; int **p = parray; void **vp = p; *vp = new double();
The type system was undermined.
That is, the problem is that in the second case there are operations that can be applied to the destination pointer, which can modify the original object and cause errors. Similar examples can be found in other cases (t26) (you can convert int* to const int* , but you cannot convert int** to const int** ...).
source share