Pointer to different types can have different sizes.
You can store a pointer to any type into a void *
and then you can recover it back but this means simply that a void *
must be large enough to hold all other pointers.
Treating a variable that is holding an int *
like it's indeed a void *
is instead, in general, not permitted.
Note also that doing a cast (e.g. casting to int *
the result of malloc
) is something completely different from treating an area of memory containing an int *
like it's containing a void *
. In the first case the compiler is informed of the conversion if needed, in the second instead you're providing false information to the compiler.
On X86 however they're normally the same size and you're safe if you just play with pointers to data (pointers to functions could be different, though).
About aliasing any write operation done through a void *
or a char *
can mutate any object so the compiler must consider aliasing as possible.
Here however in your example you're writing through a void **
(a different thing) and the compiler is free to ignore potentially aliasing effects to int *
.