From owner-freebsd-hackers Sat Feb 15 17:12:37 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id RAA00818 for hackers-outgoing; Sat, 15 Feb 1997 17:12:37 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id RAA00809 for ; Sat, 15 Feb 1997 17:12:31 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id SAA06537; Sat, 15 Feb 1997 18:09:52 -0700 From: Terry Lambert Message-Id: <199702160109.SAA06537@phaeton.artisoft.com> Subject: Re: Sun Workshop compiler vs. GCC? To: hamby@aris.jpl.nasa.gov (Jake Hamby) Date: Sat, 15 Feb 1997 18:09:52 -0700 (MST) Cc: davem@jenolan.rutgers.edu, asami@vader.cs.berkeley.edu, jmb@freefall.freebsd.org, hackers@FreeBSD.ORG In-Reply-To: from "Jake Hamby" at Feb 15, 97 04:01:19 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk [ ... SunSoft C optimizer bug ... ] > In my programming career, I've discovered one other optimizer bug, in > Metrowerks Codewarrior (BeOS/PowerPC). It was rather gratifying to see it > fixed in the very next patch release, with my example code listed in the > README under bugs fixed. :) Go to a platform using the "portable C compiler" (like Ultrix). Compile a program that does: char * func2( p, len) char *p; int len; { return( p + len); } char * func( param) char *param; { register char *p = param; p = func2( p, 3); /* XXX*/ return( p); } main() { char *str = "long string"; printf( "<%s>\n", str); str = func( str); printf( "<%s>\n", str); } What will happen is that the assignment of the return value will occur before the pop, and both strings will print the same as the pop overwrites the return value. This is the "Berkeley pop order bug". Now try compiling an unmodified Motif 1.x on Ultrix. 8-). Regards, Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.