[comp.sys.atari.st] MWC bug with structure assignment

pc@ukc.ac.uk (R.P.A.Collinson) (12/30/86)

On the whole MWC implements structure assignment correctly.  However I
have found that an attempt to pass the result of a function returning
a structure into a routine as a parameter fails.

Perhaps a little example will make this clearer.

typedef struct
{	short	x;
	short	y;
} Point;

main()
{	Point pt;
	Point Pt();

	pt = Pt(100, 200)
	print_pt(pt);		/* works */

	print_pt(Pt(100, 200));	/* fails */
}

Point
Pt(x, y)
short x, y;
{	Point re;

	re.x = x; re.y = y;
	return(re);
}

print_pt(pt)
Point pt;
{	printf("x = %d, y  %d\n", pt.x, pt.y);	}

In the fail case, a pointer to a static(?) area gets passed into the code
and is not dealt with correctly.

I guess this is a case of `me need compiler fix' unless someone else
has a fix? This bug means that I cannot port a whole bunch of code using
Points and Rectangles using MWC.

PS. I am annoyed that I always seem to act as an unpaid compiler debugger for
the various commercial C compilers around.