AnsweredAssumed Answered

Cosmic compiler unexpected result

Question asked by horton.peter on Feb 1, 2013
Latest reply on Feb 8, 2013 by WoRo
Hi.

I'm using the Cosmic STM8 compiler ("free" version, v4.3.9) and it appears to generate unexpected results for the following test :-

static char test(unsigned int x, unsigned int y)
{
   return (int)(x - y) < 0;
}

This function unexpectedly returns 0 when presented with the values x=0x7f80 and y=0x8080.

If I modify the function thus is then returns 1 as expected :-

static char test(unsigned int x, unsigned int y)
{
   x -= y;

   return (int) x < 0;
}

Am I misunderstanding what the result should be ?

P.

Outcomes