home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Bug_Fixes / Net.v7bugs / 0004 < prev    next >
Encoding:
Text File  |  1981-05-28  |  752 b   |  30 lines

  1. Aucbvax.114
  2. NET.v7bugs
  3. utzoo!duke!vax135!ucbvax!mark
  4. Sun May 18 22:59:08 1980
  5. c2
  6. >From mark Sat Apr 19 01:18:51 1980
  7. To: v7bugs
  8. Subject: bug in pdp-11 C optimizer
  9. The following program demonstrates a bug in the V7 pdp-11 /lib/c2.
  10. #include <stdio.h>
  11. main () {
  12.     int x;
  13.     int t1;
  14.  
  15.     x = 0;
  16.     x += 1;
  17.     t1 = x != 1;
  18.     printf("x=%d, t1=%d\n", x, t1);
  19.     exit(0);
  20. }
  21. It should print 1, 0, but it prints 1, 1.  Seems that the optimizer has
  22. correctly noticed that the value of x can be predicted at compile time
  23. and hence the comparison can be precomputed, but it does the precomputation
  24. wrong.  Changing the 2 assignments to x to "x = 1" works properly.
  25.  
  26. I don't have a fix for this, but dmr's (more recent than v7) version of
  27. c2 seems to handle it correctly.
  28.     Mark
  29.  
  30.