ultrixcc.c 666 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <stdio.h>
  2. /*-
  3. * This is a cc optimiser bug for ultrix 4.3, mips CPU.
  4. * What happens is that the compiler, due to the (a)&7,
  5. * does
  6. * i=a&7;
  7. * i--;
  8. * i*=4;
  9. * Then uses i as the offset into a jump table.
  10. * The problem is that a value of 0 generates an offset of
  11. * 0xfffffffc.
  12. */
  13. main()
  14. {
  15. f(5);
  16. f(0);
  17. }
  18. int f(a)
  19. int a;
  20. {
  21. switch (a & 7) {
  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. }