Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-2503.c
blobbaafc50e639622507e469bdb3c6b0817673bc1c2
1 /*
2 bug-2503
3 */
5 #include <testfwk.h>
7 /* Make sure side-effects are preserved when optimizing */
8 /* conditional tests. */
10 unsigned int x;
12 unsigned int test1(void)
14 unsigned int a=0;
15 if ((a=0x55) >= 0)
16 x++;
17 return a;
20 unsigned int test2(void)
22 return x++;
25 void
26 testBug(void)
28 x = 0;
29 ASSERT(test1() == 0x55);
30 ASSERT(x == 1);
31 ASSERT(test1() == test1());
32 ASSERT(x == 3);
33 ASSERT((test2() - test2()) != 0);
34 ASSERT(x == 5);