2
0

sgiccbug.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* NOCW */
  2. /* sgibug.c */
  3. /* bug found by Eric Young (eay@mincom.oz.au) May 95 */
  4. #include <stdio.h>
  5. /* This compiler bug it present on IRIX 5.3, 5.1 and 4.0.5 (these are
  6. * the only versions of IRIX I have access to.
  7. * defining FIXBUG removes the bug.
  8. * (bug is still present in IRIX 6.3 according to
  9. * Gage <agage@forgetmenot.Mines.EDU>
  10. */
  11. /* Compare the output from
  12. * cc sgiccbug.c; ./a.out
  13. * and
  14. * cc -O sgiccbug.c; ./a.out
  15. */
  16. static unsigned long a[4]={0x01234567,0x89ABCDEF,0xFEDCBA98,0x76543210};
  17. static unsigned long b[4]={0x89ABCDEF,0xFEDCBA98,0x76543210,0x01234567};
  18. static unsigned long c[4]={0x77777778,0x8ACF1357,0x88888888,0x7530ECA9};
  19. main()
  20. {
  21. unsigned long r[4];
  22. sub(r,a,b);
  23. fprintf(stderr,"input a= %08X %08X %08X %08X\n",a[3],a[2],a[1],a[0]);
  24. fprintf(stderr,"input b= %08X %08X %08X %08X\n",b[3],b[2],b[1],b[0]);
  25. fprintf(stderr,"output = %08X %08X %08X %08X\n",r[3],r[2],r[1],r[0]);
  26. fprintf(stderr,"correct= %08X %08X %08X %08X\n",c[3],c[2],c[1],c[0]);
  27. }
  28. int sub(r,a,b)
  29. unsigned long *r,*a,*b;
  30. {
  31. register unsigned long t1,t2,*ap,*bp,*rp;
  32. int i,carry;
  33. #ifdef FIXBUG
  34. unsigned long dummy;
  35. #endif
  36. ap=a;
  37. bp=b;
  38. rp=r;
  39. carry=0;
  40. for (i=0; i<4; i++)
  41. {
  42. t1= *(ap++);
  43. t2= *(bp++);
  44. t1=(t1-t2);
  45. #ifdef FIXBUG
  46. dummy=t1;
  47. #endif
  48. *(rp++)=t1&0xffffffff;
  49. }
  50. }