Hi
I have a code snippet that does not work. When I look at the disassembled code It looks like the compiler generates incorrect code when I am optimizing for size with optimization level 3. I if change optimization level to 2, it works fine.
I have tested this in the simulator as well as on a real chip, the results are the same.
The problem is that despite the fact that i == 0, the assert is triggered.
Code:
#define ASSERT(x) if (!(x)) my_assert();
#define CHECK_PARAMS(p) (((p) == 33) || ((p) == 0))
static int g_i = 0;
int get_i(void)
{
volatile *n = &g_i;
return *n;
}
void my_assert(void)
{
while(1)
;
}
int main(void)
{
volatile int i = get_i();
ASSERT(CHECK_PARAMS(i));
while(1);
}
Target chip: STM8S207C8
I am using the large rom model.
Compiler version: 2.54.14.0283
Best Regards
Andreas
Dear Andreas,
I confirm the bug and we are sorry for the inconvenience.
This issue is fixed in the latest release you can find at http://support.raisonance.com/node/237052
regards,