GNU bug report logs - #31688
26.1.50; Byte compiler confuses two string variables

Previous Next

Package: emacs;

Reported by: Gemini Lasswell <gazally <at> runbox.com>

Date: Sat, 2 Jun 2018 17:53:01 UTC

Severity: normal

Tags: notabug

Found in version 26.1.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Noam Postavsky <npostavs <at> gmail.com>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: Gemini Lasswell <gazally <at> runbox.com>, bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz <at> gnu.org>, 31688 <at> debbugs.gnu.org
Subject: bug#31688: 26.1.50; Byte compiler confuses two string variables
Date: Sat, 02 Jun 2018 19:54:40 -0400
Phil Sainty <psainty <at> orcon.net.nz> writes:

> On 2018-06-03 06:02, Noam Postavsky wrote:
>> I don't think this is a bug, the compiler coalesces equal string
>> literals.
>
> Ouch.  Has this always been the case?  I've been firmly under the
> impression that the lisp reader creates a new lisp objects whenever
> it reads a string,

Strictly speaking, that is correct.  The reader does that.  The byte
compiler doesn't preserve the object identity.

(byte-compile (lambda () (let ((str1 "abc")
                               (str2 "abc"))
                           (eq str1 str2))))
;=> #[0 "<bytecode>" ["abc"] 4]

> But this is nil regardless:
>
> (eq "abc" "abc")

Oh, looks like the compiler performs the `eq' call at compile time.

(byte-compile (lambda () (eq "abc" "abc")))
;=> #[0 "\300\207" [nil] 1]

> This seems kinda horrible?

What, you don't like optimization? ;)





This bug report was last modified 7 years and 67 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.