[comp.lang.clu] Yet another linker bug + fix

jokinen@tucos.UUCP (Matti Jokinen) (12/28/87)

Description:  An attempt to overload a module with more than one parameter
may crash the debugger.  The bug appears at least in VAX CLU.

Repeat-by:  Compile the following program into c.bin:

    c = cluster is create

	rep = string

	create = proc[t,u: type](x: t, y: u,
				 p: proctype(t) returns(rep),
				 q: proctype(u) returns(rep))
		     returns(cvt)
	  return(p(x))
	end create

    end c

Type `debug c', and when the linker prompt appears, type `load("c")'.

Although the symptoms are very similar, this bug is unrelated to the bug
I reported in article 22.

Fix: The true origin of this problem appears to be the following equate
in /usr/clu/link/linker.equ:

    params = sequence[constant]

I think it should be

    params = oneof[dummy: null, list: sequence[constant]]

However, changing this would cause a number of changes in various parts
of the linker.  I am reluctant to maintain a system that differs too
much from the `official' MIT version.  Also, these changes may depend on
the linker version you have.

Thus I prefere a quick fix, and fortunately there is one.  Redefine the
Copy procedure in /usr/clu/link/clu/constant.  The original definition is

    Copy = proc (C: cvt) returns (cvt);
	return (rep$Copy1(C));
	end Copy;

Replace it with

    Copy = proc (C: cvt) returns (cvt);
	tagcase C
	    tag a_Null:	return(C);
	    others:	return (rep$Copy1(C));
	    end;
	end Copy;