2
0

ultrixcc.c 584 B

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