From 91625692921a0e19799f386890bfa316816c9cf8 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 1 Apr 2018 12:02:52 -0700 Subject: compiler: bug: indirect function calls. * share/txr/stdlib/compiler.tl (comp-call): We must not use the output register oreg for compiling the expression which calculates the function because it could be one of the arguments. In that case, we clobber an argument before we have called the function. --- share/txr/stdlib/compiler.tl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'share') diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 57b56828..fc80d178 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -825,8 +825,10 @@ (defmeth compiler comp-call (me oreg env opcode args) (tree-bind (fform . fargs) args - (let* ((ffrag me.(compile oreg env fform)) + (let* ((foreg me.(alloc-treg)) + (ffrag me.(compile foreg env fform)) (cfrag me.(comp-call-impl oreg env opcode ffrag.oreg fargs))) + me.(free-treg foreg) (new (frag cfrag.oreg (append ffrag.code cfrag.code) -- cgit v1.2.3