home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 13140 < prev    next >
Encoding:
Text File  |  1992-09-02  |  997 b   |  34 lines

  1. Xref: sparky comp.lang.c:13140 comp.sys.sun.misc:4056
  2. Newsgroups: comp.lang.c,comp.sys.sun.misc
  3. Path: sparky!uunet!cs.utexas.edu!uwm.edu!news.mr.med.ge.com!carl@aslmr-serv.med.ge.com
  4. From: carl@aslmr-serv.med.ge.com (Carl Crawford)
  5. Subject: sun cc optimization failure
  6. Message-ID: <1992Sep3.040401.16902@mr.med.ge.com>
  7. Sender: news@mr.med.ge.com
  8. Nntp-Posting-Host: aslmr-gate2
  9. Reply-To: carl@aslmr-serv.med.ge.com (Carl Crawford)
  10. Organization: GE Medical Systems, Milwaukee,  WI
  11. Date: Thu, 3 Sep 92 04:04:01 GMT
  12. Lines: 20
  13.  
  14.  
  15. consider the following program:
  16.  
  17. main() {
  18.     int i,j,ax;
  19.     ax = 0;
  20.     for(i=0;i<3;i++){
  21.         j = ax * i;
  22.         puts("in for loop");
  23.     }
  24. }
  25. when compiled with cc (sun os 4.1 on sparc 1+), the 
  26. code runs thru the loop three times. when comiled with 
  27. the -O flag it only runs once. hom come the optimization 
  28. screws up the loop?
  29. --
  30. Carl R. Crawford       Voice: 414-521-6572
  31. GE Medical Systems       Fax: 414-521-6575
  32. P.O. Box 414, W-875       Internet: crawfordc@med.ge.com
  33. Milwaukee, WI 53201       
  34.