home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Bug_Fixes / Net.v7bugs / 0055 < prev    next >
Encoding:
Text File  |  1982-01-08  |  736 b   |  38 lines

  1. Autah-cs.157
  2. net.bugs.v7
  3. utzoo!decvax!duke!chico!zeppo!harpo!utah-cs!lepreau
  4. Wed Jan  6 12:25:21 1982
  5. Another C compiler bug
  6. While I'm at it, here's another apparent bug in the v7 Ritchie compiler
  7. which Spencer Thomas found.  We have no fix, does anyone?
  8. ------------------
  9. From: thomas
  10. Subj: C compiler bug
  11. Try this:
  12. {
  13.     char a[2][2];
  14.     register int i, j, k;
  15.  
  16.     a[i][j] %= k;
  17. }
  18.  
  19. and look at the assembly code:
  20.  
  21. ~a=177766
  22. ~i=r4
  23. ~j=r3
  24. ~k=r2
  25. mov    r4,r1        // figure out index into array
  26. asl    r1
  27. add    r5,r1
  28. add    r3,r1
  29. add    $-12,r1
  30. mov    r1,-(sp)    // push array address
  31. mov    r2,-(sp)    // push divisor
  32. movb    *2(sp),r1    // get a[i][j]
  33. sxt    r0        // prepare for divide
  34. div    (sp)+,r0    // do divide
  35. mov    r1,*(sp)+    // and save remainder (into a word, not a byte!!)
  36.  
  37. =S
  38.