struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2805.c
blob3a2c62b15e33569ff991dfa67cfd5f99400ff003
1 /* bug-2822.c
2 A division optimization evaluated operands to double precision only, thus losing information on long long variables.
3 */
5 #include <testfwk.h>
7 #include <limits.h>
9 unsigned long long f(void)
11 unsigned long long left = (ULLONG_MAX - 2);
12 return(left / (ULLONG_MAX - 3));
15 unsigned long long g(void)
17 unsigned long long left = (ULLONG_MAX - 2);
18 return(left % (ULLONG_MAX - 3));
21 unsigned long long fs(void)
23 unsigned long long left = (LLONG_MAX - 2);
24 return(left / (LLONG_MAX - 3));
27 unsigned long long gs(void)
29 unsigned long long left = (LLONG_MAX - 2);
30 return(left % (LLONG_MAX - 3));
33 void testBug(void)
35 ASSERT (f() == (ULLONG_MAX - 2) / (ULLONG_MAX - 3));
36 ASSERT (g() == (ULLONG_MAX - 2) % (ULLONG_MAX - 3));
37 ASSERT (fs() == (LLONG_MAX - 2) / (LLONG_MAX - 3));
38 ASSERT (gs() == (LLONG_MAX - 2) % (LLONG_MAX - 3));