I'd say it's impossible to tell, unless you convert your pointer
to (char*), but then you're comparing different kind of pointers.
A pointer points to the whole object.
If you cast a pointer to another type, lets say from double* to int*,
you get a pointer to an object that starts at the same place as the
first object. So if you cast a pointer to char*, it points to the first
byte of the object.
You cannot compare char* and void*. In your example, the compiler will
convert the (void *) v automatically to char*, so you are actually
comparing
No, (char*)v will be implicitly converted to (void*) (cf. 6.5.9#5)
and void* pointers will be compared (although I can't see what possible
difference it might make which way we do the conversion - later, the
equality semantics doesn't depend on pointer type at all).
(char *)v == (char *) (void *) v
which is guaranteed to be equal.
int v;
(void*)(char*)&v == (void*)&v;
I still don't see it (maybe it's obvious, but it's still early morning
for me and a coffee didn't help). The Standard int 6.3.2.3 (Conversions ...
Pointers) only demands that (subject to alignment) conversions between
pointer types are reversible. However I don't see how you can infer
from it that single int*->void* conversion must yield the same value
as double conversion int*->char*->void*. How do you do it?
Where exactly is it written that the result of pointer conversion
(provided it doesn't invoke UB) must point to the same location
as the original pointer?