fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libgloss / testsuite / libgloss.all / misc.c
blob5d082bc125211051b49c54cca34370a49b1e45fa
1 /*
2 * this file contains misc bug reports from WinBond.
3 */
4 #include <stdio.h>
5 #include <math.h>
7 #if unix
8 #define pass(x) printf("PASS: %s\n", x);
9 #define fail(x) printf("FAIL: %s\n", x);
10 #endif
13 The compare operation is error. Because the constant value 1.0 is
14 not correct. It seems compare with 0 in this statement.
16 HP-UX native:
17 dist is 0.301
18 PASS: float compare
19 *cp = be9a1cac, *cp1 = be9a1cac
20 PASS: float multiple 1
21 PASS: float multiple 2
22 32760 / (-2) = -16380
23 PASS: float divide 1
24 32760 / (-1) = -32760
25 PASS: float divide 1
26 These test only pass if the output matches:
27 Correct output is
28 1.0 = 1.000000E+00, 0.3010 = 3.000000E-01, -1.0 = -1.000000E+0
29 1.0 = 1.000000E+00, 0.3010 = 3.010000E-01, -1.0 = -1.000000E+00
30 These test only pass if the outut matches:
31 Correct output is
32 ans = 1.000000E+00, ans1 = 3.010000E-01, ans2 = -1.000000E+00
33 ans = 1.000000E+00, ans1 = 3.010000E-01, ans2 = -1.000000E+00
36 Test run on Oki:
38 dist is 0
39 PASS: float compare
40 *cp = be9a1cac, *cp1 = be9a1cac
41 PASS: float multiple 1
42 PASS: float multiple 2
43 32760 / (-2) = -2147467268
44 PASS: float divide 1
45 32760 / (-1) = 32760
46 PASS: float divide 1
47 These test only pass if the output matches:
48 Correct output is
49 1.0 = 1.000000E+00, 0.3010 = 3.000000E-01, -1.0 = -1.000000E+0
50 1.0 = 1.586860E-318, 0.3010 = -1.009091E-303, -1.0 = 5.290504E-315
51 These test only pass if the outut matches:
52 Correct output is
53 ans = 1.000000E+00, ans1 = 3.010000E-01, ans2 = -1.000000E+00
54 ans = 4.940656E-324, ans1 = -5.299809E-315, ans2 = 5.290504E-315
58 main()
60 float dist = 0.3010;
62 printf ("dist is %G\n", dist);
63 if ( dist < 1.0 ) {
64 pass ("float compare");
65 } else {
66 fail ("float compare");
69 test_1();
70 test_2();
71 test_3();
72 test_4();
74 fflush (stdout);
78 * *cp = be9a1cac, *cp1 = 00000000
80 test_1()
82 float i, ans, ans1;
83 unsigned int *cp=&ans, *cp1=&ans1;
85 i = 0.3010;
86 ans = (-1.0) * 0.3010 * 1.0; /* OK */
87 ans1 = (-1.0) * i * 1.0; /* Disaster */
88 printf ("*cp = %08x, *cp1 = %08x\n", *cp, *cp1);
90 if (*cp != 0xbe9a1cac) {
91 fail ("float multiple 1");
92 } else {
93 pass ("float multiple 1");
96 if (*cp1 != 0xbe9a1cac) {
97 fail ("float multiple 2");
98 } else {
99 pass ("float multiple 2");
104 Positive integer divide Negative integer may get interesting result.
105 For examples:
106 EX1: 32760 / (-2) = -2147467268
108 test_2()
110 int value, i, j;
112 i = 32760;
113 j = -2;
114 value = i / (j);
115 printf ("%d / (%d) = %d\n", i, j, value);
117 if (value != -16380) {
118 fail ("float divide 1");
119 } else {
120 pass ("float divide 1");
125 EX2: 32760 / (-1) = 32760
127 test_3()
129 int value, i, j;
131 i = 32760;
132 j = -1;
133 value = i / (j);
134 printf ("%d / (%d) = %d\n", i, j, value);
136 if (value != -32760) {
137 fail ("float divide 1");
138 } else {
139 pass ("float divide 1");
144 The data output format %e, %E, %g, %G in printf() can not work.
145 Please test the following example:
147 1.0 = 1.000000E+00, 0.3010 = 3.009999E-01, -1.0 = -1.000000E+00
148 ans = 4.940656E-324, ans1 = -5.299809E-315, ans2 = 5.290504E-315
150 test_4()
152 float ans, ans1, ans2;
154 ans = 1.0;
155 ans1 = 0.3010;
156 ans2 = -1.0;
158 printf ("These test only pass if the output matches:\nCorrect output is\n1.0 = 1.000000E+00, 0.3010 = 3.000000E-01, -1.0 = -1.000000E+0\n");
159 printf ("1.0 = %E, 0.3010 = %E, -1.0 = %E\n", 1.0, 0.3010, -1.0);
160 printf ("These test only pass if the outut matches:\nCorrect output is\nans = 1.000000E+00, ans1 = 3.010000E-01, ans2 = -1.000000E+00\n");
161 printf ("ans = %E, ans1 = %E, ans2 = %E\n", ans, ans1, ans2);