[net.bugs.4bsd] bug in Berkeley pascal compiler

lee@unm-cvax.UUCP (11/05/83)

	 In the Berkeley pascal compiler a segmentation fault will occur
	in the resulting a.out if one should try to pass a function as an
	argument.  This is because the routine blkcpy is receiving a bad size
	to copy. The fix is simple.

	 First, in the source directory for the runtime library the routine
	FCALL.c must be changed. The statement:
	blkcpy(frtn->fbn * sizeof(struct display),
		&_disply[1], &frtn->fdisp[frtn->fbn]);

	should be changed to:
	blkcpy(frtn->fbn * sizeof(struct display),
		&_disply[1], &(frtn->fdisp[frtn->fbn]));

	and the statement:
	blkcpy(frtn->fbn * sizeof(struct display),
		&frtn->fdisp[0], &_disply[1]);

	should be:
	blkcpy(frtn->fbn * sizeof(struct display),
		&(frtn->fdisp[0]), &_disply[1]);

	Now then ,edit the file FRTN.c in the same directory and change
	the statement:
	blkcpy(frtn->fbn * sizeof(struct display),
		frtn->fdisp[frtn->fbn], &_disply[1]);

	to:
	blkcpy(frtn->fbn * sizeof(struct display),
		&(frtn->fdisp[frtn->fbn]), &_disply[1]);

	Remake both libpc.a and libpc_p.a and install them and all
	should be well with the world!

	A test program for this problem follows...

		--Lee (Ward)
		{ucbvax, gatech, parsec}!unmvax!lee

program test (input,output);

var
	a, b:integer;

function f1 (function f(x:integer):integer; arg:integer): integer;
var
	x:integer;
begin
	x := f(arg);
	f1 := x;
end;

function f2 (x:integer):integer;
begin
	f2 := x + 1;
end;

begin
	b := 5;
	a := f1(f2, b);
	writeln (a, 'Should be 6');
end.