ultrixcc.c revision 296465
1#include <stdio.h>
2
3/*-
4 * This is a cc optimiser bug for ultrix 4.3, mips CPU.
5 * What happens is that the compiler, due to the (a)&7,
6 * does
7 * i=a&7;
8 * i--;
9 * i*=4;
10 * Then uses i as the offset into a jump table.
11 * The problem is that a value of 0 generates an offset of
12 * 0xfffffffc.
13 */
14
15main()
16{
17    f(5);
18    f(0);
19}
20
21int f(a)
22int a;
23{
24    switch (a & 7) {
25    case 7:
26        printf("7\n");
27    case 6:
28        printf("6\n");
29    case 5:
30        printf("5\n");
31    case 4:
32        printf("4\n");
33    case 3:
34        printf("3\n");
35    case 2:
36        printf("2\n");
37    case 1:
38        printf("1\n");
39#ifdef FIX_BUG
40    case 0:
41        ;
42#endif
43    }
44}
45