2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20020423-1.c
blob5f744b6f94ab415a626cc0d4ff9008fc80b695a7
1 /* PR c/5430 */
2 /* Verify that the multiplicative folding code is not fooled
3 by the mix between signed variables and unsigned constants. */
5 extern void abort (void);
6 extern void exit (int);
8 int main (void)
10 int my_int = 924;
11 unsigned int result;
13 result = ((my_int*2 + 4) - 8U) / 2;
14 if (result != 922U)
15 abort();
17 result = ((my_int*2 - 4U) + 2) / 2;
18 if (result != 923U)
19 abort();
21 result = (((my_int + 2) * 2) - 8U - 4) / 2;
22 if (result != 920U)
23 abort();
24 result = (((my_int + 2) * 2) - (8U + 4)) / 2;
25 if (result != 920U)
26 abort();
28 result = ((my_int*4 + 2U) - 4U) / 2;
29 if (result != 1847U)
30 abort();
32 exit(0);