[comp.sys.mac] LSC Bug

platt@emory.uucp (Dan Platt) (10/13/87)

-------------------------------------------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
choke on this lineater.
-------------------------------------------------------------------

-------------------------------------------------------------------

I've detected a condition where code generated by the lightspeed
C compiler causes a system crash.  This code is generated by a
simple and innocuous piece of code:

walker.x=(r=rmax+rjump)*cos(theta=2*pi*rndm());

Pulling the two assignments out of the above statement:

theta=2*pi*rndm();
r=rmax+rjump;
walker.x=r*cos(theta);

produces code which doesn't cause the system to crash (make a
little bomb dialog box).

Declarations are of the form

double rndm();
double r,rmax,rjump,theta;
#define pi 3.14159265358979
struct { double x,y} walker;

rndm() returns a random number between 0 and 1 using the
Random() function from quickdraw.

Another thing I noticed is that programs generated by LSC don't
seem to work well with Juggler.

Any idea of whether and when these are expected to be fixed would
be appreciated.

Dan

singer@endor.harvard.edu (Richard Siegel) (10/13/87)

If you can send me a small program that illustrates the problem I'll 
take a look at it, in the meantime I'll work with what I've got.

		--Rich

**The opinions stated herein are my own opinions and do not necessarily
represent the policies or opinions of my employer (THINK Technologies, Inc).

* Richard M. Siegel | {decvax, ucbvax, sun}!harvard!endor!singer    *
* Customer Support  | singer@endor.harvard.edu			    *
* THINK Technologies, Inc.  (No snappy quote)                       *

alen@cogen.UUCP (Alen Shapiro) (10/17/87)

Can any of you guys out there in THINKland tell me why this program
terminates and do I get a free upgrade to 3.0 (symbolic debugger
and all) for finding a bug (grovel grovel)?

Seems that when I add zero to a register pointer it wants to add 8.
This is an isolation of a problem in a large suite of programs I am
writing. The #define of EXTRA to zero is a place keeper for future
improvements where extra space will be (but is not currently) needed.

Nevertheless I'm sure the compiler should not generate code that
adds a different definition of zero ((-: you know, the one more closely
related to 42 - the definition of zero that we have not yet come
across :-)).

--alen the Lisa slayer (it's a long story)

	...!seismo!esosun!cogen!alen

-----cut here----
#include <stdio.h>

/* on */
#define BUG	/* adding 0 to a register pointer adds 8 is this an
		 * overenthusiastic allignment preservation effect?
		 */

#define EXTRA 0

main() {
#ifdef BUG
	register char *c;
#else BUG
	char *c;
#endif BUG
	
	for(c=(char *)0 ; c < (char *)100 ; c += EXTRA)
		fprintf(stderr, "c = 0x%lx\n", c);
}

stew@endor.harvard.edu (Stew Rubenstein) (10/18/87)

In article <372@cogen.UUCP> alen@cogen.UUCP (Alen Shapiro) writes:
>Seems that when I add zero to a register pointer it wants to add 8.

I bet it's assembling an ADDQ #0, A3 instruction or something like
that.  The 680x0 interprets that as ADDQ #8, A3 since adding zero
is useless and it's a three bit field.
Stew Rubenstein
Cambridge Scientific Computing, Inc.
UUCPnet:    seismo!harvard!rubenstein            CompuServe: 76525,421
Internet:   rubenstein@harvard.harvard.edu       MCIMail:    CSC