Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!sun-spots-request From: elsie!ado@ncifcrf.gov (Arthur David Olson) Newsgroups: comp.sys.sun Subject: Sun 4.1 cc's -O is broken on Sun 3's for levels greater than 1 Keywords: SunOS Message-ID: <8190@brazos.Rice.edu> Date: 26 May 90 22:53:54 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 63 Approved: Sun-Spots@rice.edu X-Sun-Spots-Digest: Volume 9, Issue 180, message 17 Here's an excerpt from a bug report that's gone off to Sun. Description: The SunOS 4.1 C compiler's optimizer is broken on Sun 3's for optimization levels above 1. Repeat-By: Note the different output below when compiling with different flags. Script started on Sat May 26 18:48:20 1990 elsie$ uname -a SunOS elsie 4.1 1 sun3 elsie$ cat try.c #include "stdio.h" cgf2(x) { int dir, step, steps; (void) printf("%d\n", x); steps = (x == 50) ? 2 : 0; dir = -1; for (step = steps; step > 0; --step) cgf2(x + dir * step); } main() { cgf2(50); } elsie$ cc try.c elsie$ a.out 50 48 49 elsie$ cc -g try.c elsie$ a.out 50 48 49 elsie$ cc -O1 try.c elsie$ a.out 50 48 49 elsie$ cc -O2 try.c elsie$ a.out 50 48 elsie$ cc -O try.c elsie$ a.out 50 48 elsie$ exit script done on Sat May 26 18:49:05 1990 Workaround: Don't use optimization levels greater than one. Arthur David Olson ado@alw.nih.gov ADO is a trademark of Ampex.