unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: 20862@debbugs.gnu.org
Subject: bug#20862: 25.0.50; 32-bit Emacs configured --with-wide-int miscompiles CL
Date: Sat, 27 Jun 2015 11:01:53 -0700	[thread overview]
Message-ID: <558EE511.1060609@cs.ucla.edu> (raw)
In-Reply-To: <87mvzlun07.fsf@igel.home>

[-- Attachment #1: Type: text/plain, Size: 523 bytes --]

Andreas Schwab wrote:
> That isn't true.  #: prefixed symbols are uninterned symbols.

Good point, thanks.  The doc I quoted predates the #: syntax, and evidently 
wasn't updated when the #: syntax was introduced and used.  Since that doc 
wording is wrong, and there's now no reason to initialize cl--gensym-counter to 
anything other than 0, I boldly installed the attached patch.  It passes 'make 
bootstrap' and 'make check' (at least, as well as 'make check' did before -- it 
always fails for me in epg-roundtrip-2).

[-- Attachment #2: 0001-Initialize-cl-gensym-counter-to-0.patch --]
[-- Type: text/x-diff, Size: 4035 bytes --]

From c66ff5757c6eeb495eeb283f34fc0713d1fb5270 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 27 Jun 2015 10:57:02 -0700
Subject: [PATCH] Initialize cl--gensym-counter to 0

Previously it was initialized to a random value, which made it
harder to reproduce earlier Emacs runs.  The need for a random
value went away when Emacs introduced and used the #: syntax for
uninterned symbols (Bug#20862).
* doc/misc/cl.texi (Creating Symbols, Common Lisp Compatibility):
Document that cl--gensym-counter now starts with 0.
* lisp/emacs-lisp/cl-lib.el (cl--gensym-counter): Remove.
(cl--random-time): Move to near only remaining use.
* lisp/emacs-lisp/cl-macs.el (cl--gensym-counter): Initialize to 0.
---
 doc/misc/cl.texi           | 15 +++------------
 lisp/emacs-lisp/cl-lib.el  | 15 +++++----------
 lisp/emacs-lisp/cl-macs.el |  2 +-
 3 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index d7b3f4a..1f38ca9 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -2877,14 +2877,8 @@ their names will not conflict with ``real'' variables in the user's
 code.
 
 (Internally, the variable @code{cl--gensym-counter} holds the counter
-used to generate names.  It is incremented after each use.  In Common
-Lisp this is initialized with 0, but this package initializes it with
-a random time-dependent value to avoid trouble when two files that
-each used @code{cl-gensym} in their compilation are loaded together.
-Uninterned symbols become interned when the compiler writes them out
-to a file and the Emacs loader loads them, so their names have to be
-treated a bit more carefully than in Common Lisp where uninterned
-symbols remain uninterned after loading.)
+used to generate names.  It is initialized with zero and incremented
+after each use.)
 @end defun
 
 @defun cl-gentemp &optional x
@@ -4543,10 +4537,7 @@ example, local @code{special} declarations, which are purely
 advisory in Emacs Lisp, do not rigorously obey the scoping rules
 set down in Steele's book.
 
-The variable @code{cl--gensym-counter} starts out with a pseudo-random
-value rather than with zero.  This is to cope with the fact that
-generated symbols become interned when they are written to and
-loaded back from a file.
+The variable @code{cl--gensym-counter} starts out with zero.
 
 The @code{cl-defstruct} facility is compatible, except that structures
 are of type @code{:type vector :named} by default rather than some
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index b6f3a79..2dd0519 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -249,16 +249,6 @@ so that they are registered at compile-time as well as run-time."
       `(progn ,@body))))           ; Avoid loading cl-macs.el for cl-eval-when.
 
 
-;;; Symbols.
-
-(defun cl--random-time ()
-  (let* ((time (copy-sequence (current-time-string))) (i (length time)) (v 0))
-    (while (>= (cl-decf i) 0) (setq v (+ (* v 3) (aref time i))))
-    v))
-
-(defvar cl--gensym-counter (* (logand (cl--random-time) 1023) 100))
-
-
 ;;; Numbers.
 
 (define-obsolete-function-alias 'cl-floatp-safe 'floatp "24.4")
@@ -298,6 +288,11 @@ If true return the decimal value of digit CHAR in RADIX."
   (let ((n (aref cl-digit-char-table char)))
     (and n (< n (or radix 10)) n)))
 
+(defun cl--random-time ()
+  (let* ((time (copy-sequence (current-time-string))) (i (length time)) (v 0))
+    (while (>= (cl-decf i) 0) (setq v (+ (* v 3) (aref time i))))
+    v))
+
 (defvar cl--random-state
   (vector 'cl--random-state-tag -1 30 (cl--random-time)))
 
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 636c543..5bcf088 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -161,7 +161,7 @@ whether X is known at compile time, macroexpand it completely in
 
 ;;; Symbols.
 
-(defvar cl--gensym-counter)
+(defvar cl--gensym-counter 0)
 ;;;###autoload
 (defun cl-gensym (&optional prefix)
   "Generate a new uninterned symbol.
-- 
2.1.0


  reply	other threads:[~2015-06-27 18:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-21 15:30 bug#20862: 25.0.50; 32-bit Emacs configured --with-wide-int miscompiles CL Eli Zaretskii
2015-06-25  3:31 ` Paul Eggert
2015-06-25 14:30   ` Eli Zaretskii
2015-06-26 19:59     ` Paul Eggert
2015-06-26 20:39       ` Eli Zaretskii
2015-06-26 20:45         ` Paul Eggert
2015-06-26 21:30           ` Glenn Morris
2015-06-27  7:22             ` Eli Zaretskii
2015-06-27 15:56               ` Paul Eggert
2015-06-27 16:30                 ` Eli Zaretskii
2015-06-27 16:36                 ` Andreas Schwab
2015-06-27 18:01                   ` Paul Eggert [this message]
2015-06-27 18:39                     ` Eli Zaretskii
2015-06-27 18:40                       ` Paul Eggert
2015-06-27 19:41                         ` Eli Zaretskii
2015-06-28 15:48                           ` Eli Zaretskii
2015-06-28 16:01                             ` Paul Eggert
2015-06-27  7:17           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=558EE511.1060609@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=20862@debbugs.gnu.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).