unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: subtle byte-compiler bug
@ 2004-01-08  8:12 David PONCE
  0 siblings, 0 replies; 4+ messages in thread
From: David PONCE @ 2004-01-08  8:12 UTC (permalink / raw)
  Cc: emacs-pretest-bug, emacs-devel

Hi Andreas,

> Thanks for the testcase.  I have installed this change to fix the bug:
> 
> 	* print.c (print_preprocess) <case Lisp_Vectorlike>: Only mask
> 	size if PSEUDOVECTOR_FLAG is set.

It works like a charm now :-)
Thanks!

David

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: subtle byte-compiler bug
@ 2004-01-07 15:07 David PONCE
  2004-01-08  0:19 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: David PONCE @ 2004-01-07 15:07 UTC (permalink / raw)
  Cc: emacs-devel

Hi,

Oliver Scholz wrote:
> David Ponce (CCed here) suggested that this is a bug in the
> byte-compiler. He also noted that this bug is not in 21.3.
[...]

I finally got a little time to investigate on that problem and
discovered that the bug is not in the byte-compiler but in the
`prin1' primitive.

Sometimes `prin1' print incorrect uninterned symbol references,
that can result in writing invalid byte-compiled code.

Here is a small example of code that illustrates the bug:

(let* ((n 512)
       (print-escape-newlines t)
       (print-length nil)
       (print-level nil)
       (print-quoted t)
       (print-gensym t)
       (v (make-vector n (list 1 2 3)))
       (tmp1 (make-symbol "defconst-tmp-var"))
       (tmp2 (make-symbol "defconst-tmp-var"))
       )
  (aset v 3 `(lambda (,tmp1) (defconst v1  ,tmp1)))
  (aset v 8 `(lambda (,tmp2) (defconst v2 ,tmp2)))
  (prin1 v))

When I eval it in the *scratch* buffer, `prin1' print something like
the following, which is obviously incorrect :-(

[(1 2 3) (1 2 3) (1 2 3)
 (lambda (#:defconst-tmp-var) (defconst v1 #:defconst-tmp-var))
 (1 2 3) (1 2 3) (1 2 3) (1 2 3)
 (lambda (#:defconst-tmp-var) (defconst v2 #:defconst-tmp-var))
 (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) ...]

However, If I simply change (n 512) to (n 511) in the `let'
expression, the printed result is then correct:

[(1 2 3) (1 2 3) (1 2 3)
 (lambda (#1=#:defconst-tmp-var) (defconst v1 #1#))
 (1 2 3) (1 2 3) (1 2 3) (1 2 3)
 (lambda (#2=#:defconst-tmp-var) (defconst v2 #2#))
 (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) ...]

I am running:

GNU Emacs 21.3.50.1 (i686-pc-linux-gnu, GTK+ Version 2.2.4)
 of 2004-01-07
configured using `configure '--prefix=/home/ponce' '--with-x-toolkit=gtk''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Hope this will help.

Sincerely,
David

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-01-08 13:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-08  8:12 subtle byte-compiler bug David PONCE
  -- strict thread matches above, loose matches on Subject: below --
2004-01-07 15:07 David PONCE
2004-01-08  0:19 ` Andreas Schwab
2004-01-08 13:38   ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).