For a unit test of C dode, I want to ascertain that a value passed as a void *
is, indeed, a valid pointer.
I don't think that I can prove that it definitely is a valid pointer, but how can I say that it probably is? Or definitely is not?
I am developing and unit testing on a 64 bit Intel processor, and the target is an ARM 9. I am not averse to assembler inserts.
- is there a minimum value for a valid pointer?
0x08
doesn't look very pointer-ish, wheras values above0x1000000
do. - must it be divisible by something (say 8)?
- can I say with 100% certainty that an odd number is not a valid pointer?
I don't need a flawless answer, just something to catch most errors.
[Update] I am considering looking at the link map, although that seems like overkill. The problem is occuring when casting to remove compiler wanrings. Some system calls require a char *
or void *
, and csting to those is masking some coding errors.