GNU bug report logs -
#66696
29.1; "A bug in the function debug."
Previous Next
Reported by: Lewis Creary <lewcreary <at> cs.com>
Date: Mon, 23 Oct 2023 05:47:01 UTC
Severity: normal
Found in version 29.1
Fixed in version 30.1
Done: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66696 in the body.
You can then email your comments to 66696 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66696
; Package
emacs
.
(Mon, 23 Oct 2023 05:47:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Lewis Creary <lewcreary <at> cs.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 23 Oct 2023 05:47:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
While I was trying to diagnose a bug in the function displayed just belowwith the help of the function debug, the interim values of the lisp variables shown were inconsistent with the code being debugged. For example, when called with the argument 5, the first element of the remainder list should be 1 (5 divided by 2 leaves a remainder of 1). However, the fn debug claims that the variable `rmdr-list' has the first element 0. This is just wrong! And it has nothing to do with the problem being debugged.
(defun dec-to-bin (n) (let ((dividend n) (rmdr-list nil) (stop-sw nil) (numstr "") ) (while ((and (>= dividend 0) (not stop-sw))) (setq dividend (/ dividend 2) rmdr-list (append (list (% dividend 2)) rmdr-list) ) (if (= dividend 0) (setq stop-sw t)) ) (debug) ) (while rmdr-list (setq numstr (concat numstr (number-to-string (car rmdr-list))) rmdr-list (cdr rmdr-list) ) ) (string-to-number numstr) ))-----------------------------------------------------In GNU emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-08-02 built on AVALONWindowing system distributor 'Microsoft Corp.', version 10.0.22621System Description: Microsoft Windows 10 Home (v10.0.2009.22621.2428)Configured using: 'configure --with-modules --without-dbus --with-native-compilation=aot --without-compress-install --with-tree-sitter CFLAGS=-O2'
Configured features:ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMPNOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFFTOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB
(NATIVE_COMP present but libgccjit not available)
Important settings: value of $LANG: ENU locale-coding-system: cp1252
Major mode: Lisp Interaction
Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66696
; Package
emacs
.
(Mon, 23 Oct 2023 06:58:01 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
Lewis Creary via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:
> While I was trying to diagnose a bug in the function displayed just below
> with the help of the function debug, the interim values of the lisp variables shown were inconsistent with the code being debugged. For example,
> when called with the argument 5, the first element of the remainder list should be 1 (5 divided by 2 leaves a remainder of 1). However, the fn
> debug claims that the variable `rmdr-list' has the first element 0. This is just wrong! And it has nothing to do with the problem being debugged.
>
> (defun dec-to-bin (n)
> (let ((dividend n)
> (rmdr-list nil)
> (stop-sw nil)
> (numstr "") )
> (while ((and (>= dividend 0) (not stop-sw)))
> (setq dividend (/ dividend 2)
> rmdr-list (append (list (% dividend 2)) rmdr-list) )
> (if (= dividend 0)
> (setq stop-sw t)) )
DId you get your parentheses right? The above ')' is the end of the while...
> (debug) )
> (while rmdr-list
> (setq numstr (concat numstr (number-to-string (car rmdr-list)))
> rmdr-list (cdr rmdr-list) ) )
> (string-to-number numstr) ))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66696
; Package
emacs
.
(Mon, 23 Oct 2023 06:58:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66696
; Package
emacs
.
(Mon, 23 Oct 2023 19:13:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 66696 <at> debbugs.gnu.org (full text, mbox):
Lewis Creary <lewcreary <at> cs.com> writes:
(Please reply to all, so that your mails get to the bug tracker.)
>>> Did you get your parentheses right? The above ')' is the end of the while.
>
> I checked, and the extra parenthesis is in my bug report, but not in the code I tried to run. I'd be interested to know if you can reproduce my
> problem in emacs lisp, with correct parentheses.
>
> -- Lew Creary
1: (while ((and (>= dividend 0) (not stop-sw)))
2: (setq dividend (/ dividend 2)
3: rmdr-list (append (list (% dividend 2)) rmdr-list) )
You write in the bug report that you start with dividend being 5, and
you expect the first element of the list to be 1, but it is 0.
When you look at line 2, dividend is divided by 2, which results in 5 /
2 = 2, because this is integer division. In line 3, you compute the rest
of dividend (which is now 2) when divided by 2, which results in 0.
So, this looks correct.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66696
; Package
emacs
.
(Sun, 05 Nov 2023 06:02:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 66696 <at> debbugs.gnu.org (full text, mbox):
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
> Lewis Creary <lewcreary <at> cs.com> writes:
>
> (Please reply to all, so that your mails get to the bug tracker.)
>
>>>> Did you get your parentheses right? The above ')' is the end of the while.
>>
>> I checked, and the extra parenthesis is in my bug report, but not in the code I tried to run. I'd be interested to know if you can reproduce my
>> problem in emacs lisp, with correct parentheses.
>>
>> -- Lew Creary
>
> 1: (while ((and (>= dividend 0) (not stop-sw)))
> 2: (setq dividend (/ dividend 2)
> 3: rmdr-list (append (list (% dividend 2)) rmdr-list) )
>
> You write in the bug report that you start with dividend being 5, and
> you expect the first element of the list to be 1, but it is 0.
>
> When you look at line 2, dividend is divided by 2, which results in 5 /
> 2 = 2, because this is integer division. In line 3, you compute the rest
> of dividend (which is now 2) when divided by 2, which results in 0.
>
> So, this looks correct.
No further reaction expected at this point, so I'm closing this.
bug marked as fixed in version 30.1, send any further explanations to
66696 <at> debbugs.gnu.org and Lewis Creary <lewcreary <at> cs.com>
Request was from
Gerd Möllmann <gerd.moellmann <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 05 Nov 2023 06:02:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 03 Dec 2023 12:24:11 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 202 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.