Subject: Re: 24.1; Spurious bytecomp warning "might not be defined at runtime" when using advice in required file

From: Alan Mackenzie <[email-masked]>
Date: Wed, 25 Nov 2015 10:25:05 +0000

Hello, Michael.

Sorry it's taken a long time to get back to you.

On Wed, Jul 11, 2012 at 04:39:58PM -0700, Michael Hoffman wrote:

> Please describe exactly what actions triggered the bug, and
> the precise symptoms of the bug.  If you can, give a recipe
> starting from `emacs -Q':

> ====
> cat > outer.el << EOF
> (eval-when-compile (add-to-list 'load-path "."))

> (require 'inner)
> EOF

> cat > inner.el << EOF
> (defun inner-b ())

> (defadvice inner-b (around inner-b-1 activate)
>   (inner-a))

> (defun inner-a ())

> (provide 'inner)
> EOF

> emacs -Q -batch -f batch-byte-compile outer.el
> ====

> This produces:

> ====
> In end of data:
> outer.el:4:1:Warning: the function `inner-a' might not be defined at runtime.
> Wrote /net/noble/vol2/home/mmh1/src/experimental/bytecode/outer.elc
> ====

> I expected not to have a warning in this case as inner-a, is, in fact defined.

First of all, thanks for taking the trouble to report the problem, and
thanks even more for distilling it down to a minimal case.

What is happening is that the byte-compiler collects a list of defuns
"not yet defined for runtime" as it goes along.  This includes any
functions defined within an `eval-when-compile', here the function
`inner-a' mentioned in the `defadvice'.

When `inner-a' is later defined, it is NOT taken off this list.  This is
the bug.  The contents of that list are get output to the screen in the
"might not be defined at runtime" warning message at the end of the
compilation.

The bug has just been fixed in the Emacs project's git repository, in
branch emacs-25.  We should be releasing Emacs 25.1 several months from
now, probably in early summer 2016.

[ .... ]

> In GNU Emacs 24.1.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.18.9)
>  of 2012-06-21 on rhel6-x64.grid.gs.washington.edu
> Windowing system distributor `Red Hat, Inc.', version 11.0.11004000
> Configured using:
>  `configure '--without-gif' '--with-x' '--with-x-toolkit=gtk'
>  '--prefix=/net/gs/vol3/software/modules-sw/emacs/24.1/Linux/RHEL6/x86_64'
>  'LDFLAGS=-L/net/gs/vol3/software/modules-sw/boost/1.45.0/Linux/RHEL6/x86_64/lib/
>  -L/net/gs/vol3/software/modules-sw/R/2.9.0/Linux/RHEL6/x86_64/lib/'
>  'CPPFLAGS=-I/net/gs/vol3/software/modules-sw/boost/1.45.0/Linux/RHEL6/x86_64/include/
>  -I/net/gs/vol3/software/modules-sw/R/2.9.0/Linux/RHEL6/x86_64/include/''

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).