Hello,
I am working on AT91SAM9G20, Keil 5.10. I am passing a constant structure pointer to a function.
typedef struct { int Test; int OkFlag; }StructNode; typedef const StructNode *const Node_t
after passing the node 3 times recursively through a function
stack data is getting corrupted.
Am I doing any mistake, Please suggest.
I have abundant stack, I am not modifying any data inside the function, I have trimmed the function to minimal, for just passing a duplicate node but data variables present in the first caller are getting corrupted.
I am type casting a auto variable to const type
StructNode Node; Node_t NodePtr = &Node;
I suspect there might be issue with Node_t typecast from Node
Passing an address of a stack based variable can be tricky since the lifetime of the variable ends at the function return.
When the reference pointer of such a variable is used after that, you get a stack corruption. I suggest that you analyze your program for such a scenario.