I missed something obvious here, but consider the following,
int k = 10;
int *p = &k;
int i = (int)p;
higher,
warning: cast from pointer to integer of different size
and further
int k = 10;
int *p = &k;
int i = p;
causes,
warning: initialization makes integer from pointer without a cast
a little googling will lead me
Convert pointer to integer
which advises to use uintptr_t,
int k = 10;
int *p = &k;
int i = (uintptr_t)p;
above no errors, no warnings. So my question is: k is an int, and p is an int pointer pointing to k, why does the dereference p occur?
source
share