home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:13192 comp.sys.sun.misc:4080
- Path: sparky!uunet!mdcbbs!sysjj.mdcbbs.com!selig
- Newsgroups: comp.lang.c,comp.sys.sun.misc
- Subject: Re: sun cc optimization failure
- Message-ID: <1992Sep3.123428.1@sysjj.mdcbbs.com>
- From: selig@sysjj.mdcbbs.com
- Date: 3 Sep 92 12:34:28 GMT
- References: <1992Sep3.040401.16902@mr.med.ge.com>
- Organization: McDonnell Douglas M&E, Cypress CA
- Nntp-Posting-Host: sysjj
- Nntp-Posting-User: selig
- Lines: 23
-
- > consider the following program:
- >
- > main() {
- > int i,j,ax;
- > ax = 0;
- > for(i=0;i<3;i++){
- > j = ax * i;
- > puts("in for loop");
- > }
- > }
- > when compiled with cc (sun os 4.1 on sparc 1+), the
- > code runs thru the loop three times. when comiled with
- > the -O flag it only runs once. how come the optimization
- > screws up the loop?
- > --
- If you're entertaining wild guesses, mine is that the
- compiler picked up that since ax is zero, j will always be
- zero.
-
- Try initializing ax to a non-zero number.
-
-
- Dan
-