GNU bug report logs - #12813
gv-define-simple-setter can evaluate VAL more than once

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Tue, 6 Nov 2012 07:51:02 UTC

Severity: normal

Found in version 24.2.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #3 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: gv-define-simple-setter can evaluate VAL more than once
Date: Tue, 06 Nov 2012 02:47:25 -0500
Package: emacs
Version: 24.2.50

I don't know if you will consider this a bug.
gv-define-simple-setter with FIX-RETURN non-nil evaluates VAL twice.
This may lead to unintended behaviour.

Artificial example in `emacs -Q':

(defun foo (x)
  (car x))

(defun foo-set (x y)
  (setcar x y))

(gv-define-simple-setter foo foo-set t)

(setq bar '(1 2 3))
(setq i 0)

(setf (foo bar) (setq i (1+ i)))   ; -> 1
bar                                ; -> (2 2 3) rather than (1 2 3)


defsetf in 24.2 was documented to not have this issue
(info "(cl)Customizing Setf")
[...]

(let ((temp VALUE))
  (UPDATE-FN ARG1 ARG2 ARG3 temp)
  temp)

So at the very least this will be relevant if http://debbugs.gnu.org/12812
gets the "obvious" fix.




This bug report was last modified 12 years and 260 days ago.

Previous Next


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