AnsweredAssumed Answered

Wrong overlapping variables in RAM (CW HC08)

Question asked by Eli Litvak on Sep 22, 2006
Latest reply on Sep 22, 2006 by CompilerGuru

Recently I found that HC08 C Compiler ovelapped a local automatic variable with a global one, causing the destroy of the global var. In order to prevent it I tried to define the local variable as static and the problem was solved. Another solution was to disable some Optimizer options.
The var. definitions were:
unsigned char *Tx_ptr; // the global var.

typedef union
unsigned long l;
unsigned char arr[4];

adress_format adress; // the local automatic var.
// The adress var. is overlapping *Tx_ptr.

The solution, I found, does not satisfy me, since I haven't found the reason for the problem and the similar problem may be exist in an other place of my code, and I don't want to define all of my local variables as static (it is not economic!).
Any idea is wellcome.

Thank you in advance,