Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Feb 1997 18:09:52 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        hamby@aris.jpl.nasa.gov (Jake Hamby)
Cc:        davem@jenolan.rutgers.edu, asami@vader.cs.berkeley.edu, jmb@freefall.freebsd.org, hackers@FreeBSD.ORG
Subject:   Re: Sun Workshop compiler vs. GCC?
Message-ID:  <199702160109.SAA06537@phaeton.artisoft.com>
In-Reply-To: <Pine.GSO.3.95.970215155419.18262A-100000@aris> from "Jake Hamby" at Feb 15, 97 04:01:19 pm

next in thread | previous in thread | raw e-mail | index | archive | help
[ ... 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702160109.SAA06537>