Hi, I have a structure as Code: struct S1ap_SetUpRequest:public S1ap_MessageType { bool SupportedTAsPresence; unsigned int SupportedTAsCount ; //and many other members }; S1ap_MessageType is my Base message struct S1ap_MessageType { S1ap_ProcedureCode_Enum Procedure_Code; S1ap_MessageType_Enum Type_of_Message; }; if I declare a pointer to struct S1ap_SetUpRequest and try to access its members using pointer, Some wierd memory corruption is observed,where the address of members of structure changes. say for eg: S1ap_SetUpRequest * ptr = new S1ap_SetUpRequest ; address of (ptr->SupportedTAsPresence) at the time of creation is 8276655 Later on as the code executes address of (ptr->SupportedTAsPresence) at the time of creation is 8276658 Is this possible ?
No, it shouldn't be possible. However if you have memory corruption and if something overwrites ptr, then this could happen. Solution is to find the memory corruption and fix it.
hey!!thanks for the reply.. However, the issue was related to compiler optimisation to make the structure word align.. Giving some details about my structure. 1. It is derieved from base structure 2. The derieved structure has union defined in the structure itself 3. The derieved structure was not word aligned When the derieved structure was explicitly made word aligned the issue was resolved