Does the C standard guarantee that a value of type (T*) casted to
(void*) then back to (T*) later on, will be equal to the original
value?
Yes. More precisely, the result will *compare* equal to the
original value when using the "==" operator. This guarantee
does not cover the underlying representation, if pointers have
some "padding" bits for instance. Hence:
T *p1, *p2;
void *intermediate;
... set p1 to a valid value ...
intermediate = p1;
p2 = intermediate;
if (p1 != p2)
puts("ERROR, not equal in value");
if (memcmp(&p1, &p2, sizeof p1) != 0)
puts("equal value, but different representations");
is allowed to produce the second output line ("equal ... but
different").