Pointer points to different address after array initialisation
Hi all,
I have a weird problem when dealing with pointers and arrays. In particular, I have the following code:
Code:
#define OFFSET 0xC0000000
#define VRT_ADD 0xC1628340
#define PHYS_ADD (VRT_ADD - OFFSET)
uint8_t *Pointer_A = (uint8_t*)PHYS_ADD;
printk("Pointer_A is: 0x%X\n", Pointer_A);
uint8_t i=0;
uint8_t Array_A[15];
for (i=0; i<=15; i++)
{
Array_A[i]=0;
}
printk("Pointer_A is: 0x%X\n", Pointer_A);
After the filling of Array_A with zeros, Pointer_A points to 0x1628300, i.e. to an address which locates 64 bytes lower in memory compared to the one originally pointing to. This was observed by looking at the printks before and after the array filling:
Code:
Pointer_A is: 0x1628340
Pointer_A is: 0x1628300
If that helps, gcc version is 4.4.1 (Ubuntu 4.4.1-4ubuntu9)
Can anyone guess what is going wrong? Any help will be much appreciated!