On many systems a double
is 8 bytes wide and a pointer is 4 bytes wide. The former, therefore, would not fit into the latter.
You would appear to be abusing void*
. Your solution is going to involve allocating storage space at least as big as the largest type you need to store in some variant-like structure, e.g. a union
.