struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3504.c
blob2e6c0806f3ea0c0c3ffaaded1b71401377af3cbc
1 /*
2 bug-3504.c. An expression with an optimized-out cast was handled as if the optimized-out cast had never been there.
3 */
5 #include <testfwk.h>
7 unsigned int total = 0;
8 unsigned char prev = 255;
10 void m1() {
11 unsigned char now = 13;
12 total += (unsigned char)(now - prev); /* Code behaved as if the cast in this line was not there. */
15 void m2() {
16 unsigned char now = 13;
17 total += (unsigned char)(now + prev); /* Code behaved as if the cast in this line was not there. */
20 void
21 testBug (void)
23 m1();
24 ASSERT (total == 14);
25 m2();
26 ASSERT (total == 14 + 12);