Topic : Possible bug in the STM8S compiler

Forum : ST7/STM8

Original Post
Post Information Post
May 27, 2015 - 10:46am
Guest account

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

Replies
Post Information Post
+1
0
-1
May 27, 2015 - 10:47am
Etienne Cassin

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,