summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-01 12:02:52 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-01 12:02:52 -0700
commit91625692921a0e19799f386890bfa316816c9cf8 (patch)
tree289a74135c30a64ba8553222b358ca1d9438c50c
parent2c4403e48020fbf50f2fc3ad5e50ae5ecf69859f (diff)
downloadtxr-91625692921a0e19799f386890bfa316816c9cf8.tar.gz
txr-91625692921a0e19799f386890bfa316816c9cf8.tar.bz2
txr-91625692921a0e19799f386890bfa316816c9cf8.zip
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.
-rw-r--r--share/txr/stdlib/compiler.tl4
1 files changed, 3 insertions, 1 deletions
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)