In sdcc 3.6.5 #9842 for the following test fails (for at least hc08, stm8, mcs51-small) on my Debian GNU/Linux:
/*
int cast issue
*/
#include <testfwk.h>
#include <limits.h>
void testBug (void)
{
int i;
i = SCHAR_MAX;
ASSERT ((signed char)(i << (int)1) == -2);
}
(i << (int)1) should be 254, casting to signed char should yield -2. The test passes if the (int) is removed, or i is replaced by SCHAR_MAX.
Philipp
Diff:
Looks like a CSE bug: dumpraw1 looks ok, while dumpcse has the bug.
Philipp
Increasing priority, since the fix to #2449 is blocked by this bug.
Philipp
I started looking into this. But I think things go wrong before CSE. This is what the AST looks like and that seems fine. Note the -2 to be a signed char. For simplicity I changed the ASSERT to a returned bool.
Fixed in SDCC [r9881]