Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site unm-cvax.UUCP Path: utzoo!linus!philabs!cmcl2!lanl-a!unm-cvax!lee From: lee@unm-cvax.UUCP Newsgroups: net.bugs.4bsd Subject: bug in Berkeley pascal compiler Message-ID: <147@unm-cvax.UUCP> Date: Fri, 4-Nov-83 21:58:12 EST Article-I.D.: unm-cvax.147 Posted: Fri Nov 4 21:58:12 1983 Date-Received: Mon, 7-Nov-83 04:02:46 EST Organization: Univ. of New Mexico, Albuquerque Lines: 64 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.