1 | /* Oki bug report [OKI004](gcc005) |
---|
2 | |
---|
3 | The following computation is no work. |
---|
4 | -1 / 1 => 1 (correct -1) |
---|
5 | -1 % 2 => 1 (correct -1) |
---|
6 | */ |
---|
7 | |
---|
8 | #include <stdio.h> |
---|
9 | |
---|
10 | main () |
---|
11 | { |
---|
12 | long l1, l2, l6; |
---|
13 | auto long l3; |
---|
14 | long oza1, oza2, oza; |
---|
15 | |
---|
16 | l1 = 1; |
---|
17 | l2 = 2; |
---|
18 | l3 = -1; |
---|
19 | l6 = 6; |
---|
20 | |
---|
21 | /*** test 1 ***/ |
---|
22 | oza = ((l3 / ((l1)--)) | (l6 <= (l3 % l2))); |
---|
23 | printf ("test 1 has a result of %d.\n", oza); |
---|
24 | if (oza != -1) |
---|
25 | fail ("divide test [OKI004]"); |
---|
26 | else |
---|
27 | pass ("divide test [OKI004]"); |
---|
28 | |
---|
29 | l1 = 1; |
---|
30 | /*** test 2 ***/ |
---|
31 | oza1 = (l3 / ((l1)--)); |
---|
32 | oza2 = (l6 <= (l3 % l2)); |
---|
33 | oza = oza1 | oza2; |
---|
34 | |
---|
35 | printf ("test 2 has a result of %d.\n", oza); |
---|
36 | if (oza != -1) |
---|
37 | fail ("modulos test [OKI004]"); |
---|
38 | else |
---|
39 | pass ("modulos test [OKI004]"); |
---|
40 | fflush (stdout); |
---|
41 | |
---|
42 | test_1(); |
---|
43 | } |
---|
44 | |
---|
45 | /* |
---|
46 | 32760 / (1) = 32760 |
---|
47 | 32760 / (-1) = 32760 -------> ERROR, same as you said. |
---|
48 | 32760 / (2) = 16380 |
---|
49 | 32760 / (-2) = -2147467268 ----> ERROR |
---|
50 | 32760 / (3) = 10920 |
---|
51 | 32760 / (-3) = -1431644845 ----> ERROR |
---|
52 | 32760 / (4) = 8190 |
---|
53 | 32760 / (-4) = -8190 |
---|
54 | */ |
---|
55 | test_1() |
---|
56 | { |
---|
57 | int value, i, j; |
---|
58 | |
---|
59 | i = 32760; |
---|
60 | j = 1; |
---|
61 | value = i / (j); |
---|
62 | printf ("%d / (%d) = %d\n", i, j, value); |
---|
63 | j = -1; |
---|
64 | value = i / (j); |
---|
65 | printf ("%d / (%d) = %d\n", i, j, value); |
---|
66 | |
---|
67 | j = 2; |
---|
68 | value = i / (j); |
---|
69 | printf ("%d / (%d) = %d\n", i, j, value); |
---|
70 | j = -2; |
---|
71 | value = i / (j); |
---|
72 | printf ("%d / (%d) = %d\n", i, j, value); |
---|
73 | |
---|
74 | j = 3; |
---|
75 | value = i / (j); |
---|
76 | printf ("%d / (%d) = %d\n", i, j, value); |
---|
77 | j = -3; |
---|
78 | value = i / (j); |
---|
79 | printf ("%d / (%d) = %d\n", i, j, value); |
---|
80 | |
---|
81 | j = 4; |
---|
82 | value = i / (j); |
---|
83 | printf ("%d / (%d) = %d\n", i, j, value); |
---|
84 | j = -4; |
---|
85 | value = i / (j); |
---|
86 | printf ("%d / (%d) = %d\n", i, j, value); |
---|
87 | } |
---|
88 | |
---|