In this code: Pointer_pu32 points to variable a, but which is pointer Boot_st point to?
int * Boot_st;
int a = 15;
int * Pointer_pu32 = &a;
Boot_st = (int *)(*Pointer_pu32); /* what was this code line mean? */
When I try to run
printf("Address of A : %ld\n", &a);
printf("Boot_st : %ld\n", Boot_st);
printf("Address Boot_st : %ld\n", &Boot_st);
printf("Pointer_pu32 : %ld\n", Pointer_pu32);
Here is the result:
Address of A: 3996460
Boot_st : 15
Address Boot_st : 3996472
Pointer_pu32 : 3996460
That means: Boot_st contains the value of a, could you explain the behavior of the pointer Boot_st and Pointer_pu32?
%ldformat expects a value of the typelong int. And that (void *, cast is needed) pointers should be printed by the%pformat. Mismatchingprintfformat specifier and value type leads to undefined behavior.Boot_st = (int *)(*Pointer_pu32);is synonymous withBoot_st = a;, which is assigning anintto anint*and therefore nonsense. Besides using the wrong format specifier for printing pointers (as pointed out, should be%p), printing&Boot_stis worthless. Its address means nothing relevant to the code in question. The address it holds is relevant, but only in so far as it exercised an improper assignment fromintin the first place. And none of these has anything to do with either theembeddedornull-pointertags, which consequently should not even be here.