Subject: bug#34757: closed (Re: bug#34757: Invalid bytecode from byte compiler)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 27 Jul 2019 21:31:03 +0000

Your bug report

#34757: Invalid bytecode from byte compiler

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
34757: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=34757
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#34757: Invalid bytecode from byte compiler
From: Stefan Monnier <[email-masked]>
To: Pip Cet <[email-masked]>
Cc: [email-masked], chuntaro <[email-masked]>
Date: Sat, 27 Jul 2019 17:30:03 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

> We could fix byte-compile-out-toplevel to properly analyze how many
> stack arguments the call takes, but this patch simply treats forms
> like this as nontrivial:
>
> diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
> index 0b8f8824b4c..4e54e08ce14 100644
> --- a/lisp/emacs-lisp/bytecomp.el
> +++ b/lisp/emacs-lisp/bytecomp.el
> @@ -3025,6 +3025,7 @@ byte-compile-out-toplevel
>                         (or (null (cdr rest))
>                             (and (memq output-type '(file progn t))
>                                  (cdr (cdr rest))
> +                                (eql (length body) (cdr (car rest)))
>                                  (eq (car (nth 1 rest)) 'byte-discard)
>                                  (progn (setq rest (cdr rest)) t))))
>                    (setq maycall nil)    ; Only allow one real function call.

I installed this fix for now.

        Stefan

Subject: Invalid bytecode from byte compiler
From: chuntaro <[email-masked]>
To: [email-masked]
Date: Tue, 5 Mar 2019 17:01:00 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Invalid bytecode is output and error occurs when executed.

Byte compile the following code.

bug.el
----------------------------------------------------------------
;;; -*- lexical-binding: t; -*-

(let ((a 2))
  (print 1)
  (setq a 1))
----------------------------------------------------------------

$ emacs --batch -f batch-byte-compile bug.el

bug.elc
----------------------------------------------------------------
;ELC
...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(funcall 2 'print 1)
1
----------------------------------------------------------------

$ emacs --batch -l bug.elc
Invalid function: 2

It occurs in versions 25.2, 26.1 and HEAD.