home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:13183 comp.sys.sun.misc:4073
- Path: sparky!uunet!stanford.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
- From: torek@horse.ee.lbl.gov (Chris Torek)
- Newsgroups: comp.lang.c,comp.sys.sun.misc
- Subject: Re: sun cc optimization failure
- Supersedes: <26042@dog.ee.lbl.gov>
- Date: 3 Sep 1992 18:22:15 GMT
- Organization: Lawrence Berkeley Laboratory, Berkeley
- Lines: 38
- Message-ID: <26053@dog.ee.lbl.gov>
- References: <1992Sep3.040401.16902@mr.med.ge.com>
- Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
- NNTP-Posting-Host: 128.3.112.15
-
- [N.B.: this article is a replacement for a previous one in which I made
- an unwarranted dig at the people at Sun who work on the compilers. Current
- news systems should have deleted the other article, but some of you may
- have already seen it or have older or incompatible news systems. I
- hereby apologize to the compiler group at Sun.]
-
- In article <1992Sep3.040401.16902@mr.med.ge.com> carl@aslmr-serv.med.ge.com
- (Carl Crawford) writes:
- >consider the following program:
- >
- >main() {
- > int i,j,ax;
- > ax = 0;
- > for(i=0;i<3;i++){
- > j = ax * i;
- > puts("in for loop");
- > }
- >}
-
- This program fails strict conformance by:
-
- A: not including <stdio.h>;
- B: reaching the end of an int-valued function (main()) wihtout
- returning a value.
-
- >when compiled with cc (sun os 4.1 on sparc 1+), the code runs thru the
- >loop three times. when compiled with the -O flag it only runs once. ...
-
- After fixing the two errors above, the program still produces only
- one copy of "in for loop" when compiled with the SunOS 4.1 `cc' compiler
- using `-O'.
-
- >how come the optimization screws up the loop?
-
- The only possible answer is now ``because the compiler is broken''.
- --
- In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
- Berkeley, CA Domain: torek@ee.lbl.gov
-