There is a reason that the compiler cannot automatically drop from mystruct** to void** .
Consider the following code:
void stupid(struct mystruct **a, struct myotherstruct **b) { void **x = (void **)a; *x = *b; }
The compiler will not complain about an implicit myotherstruct* from myotherstruct* to void* on the *x = *b , although this line tries to put the pointer to myotherstruct in the place where only the pointers to mystruct .
The error is actually in the previous line, which converts "a pointer to a place where pointers to mystruct can be placed" to "a pointer to a place where pointers to anything can be placed". It is for this reason that there is no implicit throw. Of course, when you use an explicit cast, the compiler assumes that you know what you are doing.
Cesarb
source share