blob: 2e6c0806f3ea0c0c3ffaaded1b71401377af3cbc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/*
bug-3504.c. An expression with an optimized-out cast was handled as if the optimized-out cast had never been there.
*/
#include <testfwk.h>
unsigned int total = 0;
unsigned char prev = 255;
void m1() {
unsigned char now = 13;
total += (unsigned char)(now - prev); /* Code behaved as if the cast in this line was not there. */
}
void m2() {
unsigned char now = 13;
total += (unsigned char)(now + prev); /* Code behaved as if the cast in this line was not there. */
}
void
testBug (void)
{
m1();
ASSERT (total == 14);
m2();
ASSERT (total == 14 + 12);
}
|