Subject: bug#62317: 28.2; This byte-compiled file behaves wrongly.

From: Teika Kazura <[email-masked]>
Date: Tue, 21 Mar 2023 12:54:08 +0900 (JST)

Hi. In the situation below, a byte-compiled init code's evaluation is not completed, but emacs starts as if nothing was wrong.

* How to reproduce:
First, ~/.emacs.d/init.el:
------------------------------------------------------------------------
(eval-and-compile
  (push user-emacs-directory load-path)
  (require 'a))

;; Hereafter is ignored when byte-compiled.

(defvar foo-var 'baz)
(message "Hello, world.")
(pop-to-buffer "*Messages*")
------------------------------------------------------------------------

~/.emacs.d/a.el:
------------------------------------------------------------------------
(set-buffer "*Messages*") ;; or (set-buffer (get-buffer-create "bar"))
(provide 'a)
------------------------------------------------------------------------

Byte compile these two files *in this order*:
$ cd ~/.emacs.d; emacs -Q -batch -f batch-byte-compile a.el init.el

(you can now remove a.elc; it doesn't matter this bug.)
Finally, run emacs as either of these:
$ emacs -Q -l init.elc
$ emacs --no-splash --no-site-file 

* Symptom
As I commented in init.el, the code after `require' is ignored when init.el is byte-compiled. However, emacs starts as if nothing was wrong.

The line of `set-buffer' in a.el seems to trigger this bug. If you delete that line, this bug doesn't occur.

* version and build info:
In short, emacs 28 regression, but I don't know the exact version - My 28.1 was without gcc-jit, and this bug was not there. The 28.2 is built with gcc-jit, and the bug hits me.

Full build info:
------------------------------------------------------------------------
Gentoo Linux
GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.16.0) of 2023-02-02

Configured using:
 'configure --prefix=/usr --build=x86_64-pc-linux-gnu
 --host=x86_64-pc-linux-gnu --mandir=/usr/share/man
 --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
 --localstatedir=/var/lib --datarootdir=/usr/share
 --disable-silent-rules --docdir=/usr/share/doc/emacs-28.2-r4
 --htmldir=/usr/share/doc/emacs-28.2-r4/html --libdir=/usr/lib64
 --program-suffix=-emacs-28 --includedir=/usr/include/emacs-28
 --infodir=/usr/share/info/emacs-28 --localstatedir=/var
 --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
 --without-compress-install --without-hesiod --without-pop
 --with-file-notification=inotify --with-pdumper --enable-acl
 --without-dbus --with-modules --without-gameuser --with-libgmp
 --without-gpm --with-native-compilation --with-json --without-kerberos
 --without-kerberos5 --without-lcms2 --with-xml2 --without-mailutils
 --without-selinux --with-gnutls --without-libsystemd --with-threads
 --with-wide-int --with-sound=no --with-zlib --with-x --without-ns
 --without-gconf --with-gsettings --without-toolkit-scroll-bars
 --without-gif --without-jpeg --without-png --without-rsvg
 --without-tiff --without-xpm --without-imagemagick --with-xft
 --with-cairo --with-harfbuzz --with-libotf --with-m17n-flt
 --with-x-toolkit=gtk3 --without-xwidgets --with-dumping=pdumper
 'CFLAGS=-march=native -O2 -pipe' 'LDFLAGS=-Wl,-O1 -Wl,--as-needed''

Configured features:
ACL CAIRO FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JSON LIBOTF
LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER SECCOMP
THREADS X11 XDBE XIM GTK3 ZLIB
------------------------------------------------------------------------

Thanks, Emacs developers. Best regards,
Teika