I found a strange behavior when I assigned a double value to a memory allocated as unsigned integer. The double data corrupts the memory before the allocated address.
Sample code of my program
//Function to allocate memory – Returns the address void allocate_memory(unsigned int **ppu32DataAddr, unsigned int u32Length) double gdbData; double *gpdbDataAddr; int main(void) { //5.123 - 0x40147DF3 B645A1CB (Double representation) /***************************************************** //Expected Results *****************************************************/ //Address of gdbData is 0x00813300 //0x00813300 is assigned 0xB645A1CB //0x00813304 is assigned 0x40147DF3 gdbData = 5.123 /***************************************************** //Unexpected Results *****************************************************/ //gpdbDataAddr points to 0x00812FEC allocate_memory((unsigned int **)&gpdbDataAddr, 2); //0x00812FE8 is assigned 0xB645A1CB-Corrupts the previous memory location //0x00812FEC is assigned 0x40147DF3 *gpdbDataAddr = 5.123; }