Subject: bug#20241: 25.0.50; `setq' with only one argument

From: Alan Mackenzie <[email-masked]>
Date: Thu, 26 Nov 2015 12:06:19 +0000

Hello, Andreas.

On Thu, Nov 26, 2015 at 09:58:39AM +0100, Andreas Schwab wrote:
> Johan Bockgård <[email-masked]> writes:

> > (funcall) (print t)

> > Compile. Load .elc =>

> > This consistently gives me one of two results:
> > A segfault, or "Invalid function: 183795961" where the actual
> > number depends on the timestamp of the .elc file.

> That's a bug in the byte compiler, it shouldn't generate call 0 without
> an operand on the stack.

Try the following fix:

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index ffe73de..842e73d 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -4012,8 +4012,12 @@ byte-compile-while
     (setq byte-compile--for-effect nil)))
 
 (defun byte-compile-funcall (form)
-  (mapc 'byte-compile-form (cdr form))
-  (byte-compile-out 'byte-call (length (cdr (cdr form)))))
+  (if (cdr form)
+      (progn
+        (mapc 'byte-compile-form (cdr form))
+        (byte-compile-out 'byte-call (length (cdr (cdr form)))))
+    (byte-compile-log-warning "`funcall' called with no arguments" nil :error)
+    (byte-compile-form '(signal 'wrong-number-of-arguments '(funcall 0)))))
 
 
 ;; let binding

> Andreas.

-- 
Alan Mackenzie (Nuremberg, Germany).