From: Paul Eggert <eggert@cs.ucla.edu>
To: Philipp Stephani <p.stephani2@gmail.com>, Eli Zaretskii <eliz@gnu.org>
Cc: fabrice.popineau@centralesupelec.fr, andrewjmoreton@gmail.com,
emacs-devel@gnu.org
Subject: Re: Suspicious warning in W64 build
Date: Sun, 17 Sep 2017 15:34:02 -0700 [thread overview]
Message-ID: <6f175214-6fbe-4ce5-ad6e-a76c1e6e13b0@cs.ucla.edu> (raw)
In-Reply-To: <CAArVCkTDKhsg==p4Stvcc=O8oLeRKBtR8QXzhYUw_HUGpGM8Mg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 301 bytes --]
Philipp Stephani wrote:
> How about rewriting the function body like this:
Yes, that should work and avoids either UNINIT or some other pacifier. Also,
while looking at it, I noticed an actual bug in min and max, which is a plus. I
installed the attached into emacs-26, to fix both problems.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-bug-with-min-and-max-and-NaNs.patch --]
[-- Type: text/x-patch; name="0001-Fix-bug-with-min-and-max-and-NaNs.patch", Size: 2126 bytes --]
From 5f28f0db73c03b98b27e04a458ebb209b5d9acde Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 17 Sep 2017 15:25:44 -0700
Subject: [PATCH] Fix bug with min and max and NaNs
* src/data.c (minmax_driver): Fix bug with (min 0 NaN), which
mistakenly yielded 0. Also, pacify GCC in a better way.
* test/src/data-tests.el (data-tests-min): Test for the bug.
---
src/data.c | 12 ++++++------
test/src/data-tests.el | 6 +++++-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/data.c b/src/data.c
index 95bf06e..e070be6 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3010,16 +3010,16 @@ static Lisp_Object
minmax_driver (ptrdiff_t nargs, Lisp_Object *args,
enum Arith_Comparison comparison)
{
- eassume (0 < nargs);
- Lisp_Object accum = args[0]; /* pacify GCC */
- for (ptrdiff_t argnum = 0; argnum < nargs; argnum++)
+ Lisp_Object accum = args[0];
+ CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (accum);
+ for (ptrdiff_t argnum = 1; argnum < nargs; argnum++)
{
Lisp_Object val = args[argnum];
CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val);
- if (argnum == 0 || !NILP (arithcompare (val, accum, comparison)))
+ if (!NILP (arithcompare (val, accum, comparison)))
accum = val;
- else if (FLOATP (accum) && isnan (XFLOAT_DATA (accum)))
- return accum;
+ else if (FLOATP (val) && isnan (XFLOAT_DATA (val)))
+ return val;
}
return accum;
}
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index 5dc2634..8de8c14 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -101,7 +101,11 @@
(should (= 3 (apply #'min '(3 8 3))))
(should-error (min 9 8 'foo))
(should-error (min (make-marker)))
- (should (eql 1 (min (point-min-marker) 1))))
+ (should (eql 1 (min (point-min-marker) 1)))
+ (should (isnan (min 0.0e+NaN)))
+ (should (isnan (min 0.0e+NaN 1 2)))
+ (should (isnan (min 1.0 0.0e+NaN)))
+ (should (isnan (min 1.0 0.0e+NaN 1.1))))
;; Bool vector tests. Compactly represent bool vectors as hex
;; strings.
--
2.7.4
next prev parent reply other threads:[~2017-09-17 22:34 UTC|newest]
Thread overview: 123+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 13:38 Suspicious warning in W64 build Angelo Graziosi
2017-09-05 14:04 ` Richard Copley
2017-09-07 15:16 ` Eli Zaretskii
2017-09-07 15:42 ` Angelo Graziosi
2017-09-07 17:52 ` Richard Copley
2017-09-07 17:58 ` Richard Copley
2017-09-07 19:00 ` Angelo Graziosi
2017-09-07 19:21 ` Richard Copley
2017-09-09 4:58 ` Herring, Davis
2017-09-09 9:55 ` Richard Copley
2017-09-09 10:20 ` Eli Zaretskii
2017-09-09 11:24 ` Angelo Graziosi
2017-09-09 13:25 ` Eli Zaretskii
2017-09-09 11:16 ` Angelo Graziosi
2017-09-07 18:58 ` Eli Zaretskii
2017-09-07 19:26 ` Paul Eggert
2017-09-07 19:50 ` Richard Copley
2017-09-07 20:02 ` Richard Copley
2017-09-08 6:49 ` Eli Zaretskii
2017-09-08 8:02 ` Eli Zaretskii
2017-09-08 19:31 ` Richard Copley
2017-09-08 20:17 ` Eli Zaretskii
2017-09-08 21:08 ` Richard Copley
2017-09-08 21:37 ` Richard Copley
2017-09-09 7:37 ` Eli Zaretskii
2017-09-08 22:20 ` Richard Copley
2017-09-09 7:33 ` Eli Zaretskii
2017-09-09 9:36 ` Richard Copley
2017-09-09 10:42 ` Eli Zaretskii
2017-09-09 10:52 ` Eli Zaretskii
2017-09-09 11:17 ` Richard Copley
2017-09-09 16:07 ` Eli Zaretskii
2017-09-10 1:01 ` Richard Copley
2017-09-10 14:40 ` Eli Zaretskii
2017-09-10 19:14 ` Richard Copley
2017-09-10 19:38 ` Angelo Graziosi
2017-09-11 16:17 ` Eli Zaretskii
2017-09-11 22:21 ` Angelo Graziosi
2017-09-11 16:39 ` Óscar Fuentes
2017-09-11 17:20 ` Eli Zaretskii
2017-09-12 17:49 ` Eli Zaretskii
2017-09-12 18:01 ` Fabrice Popineau
2017-09-12 18:37 ` Richard Copley
2017-09-12 18:59 ` Eli Zaretskii
2017-09-12 19:14 ` Richard Copley
2017-09-12 18:38 ` Eli Zaretskii
2017-09-14 17:47 ` Eli Zaretskii
2017-09-14 19:34 ` Richard Copley
2017-09-15 8:54 ` Eli Zaretskii
2017-09-15 23:05 ` Richard Copley
2017-09-16 6:40 ` Eli Zaretskii
2017-09-16 8:19 ` Richard Copley
2017-09-16 8:34 ` Richard Copley
2017-09-16 8:54 ` Eli Zaretskii
2017-09-16 9:07 ` Richard Copley
2017-09-16 11:54 ` Fabrice Popineau
2017-09-16 8:52 ` Eli Zaretskii
2017-09-15 8:59 ` Eli Zaretskii
2017-09-15 14:43 ` Eli Zaretskii
2017-09-17 6:42 ` Paul Eggert
2017-09-17 7:14 ` Richard Copley
2017-09-17 14:31 ` Eli Zaretskii
2017-09-17 6:40 ` Paul Eggert
2017-09-17 14:29 ` Eli Zaretskii
2017-09-17 16:39 ` Fabrice Popineau
2017-09-17 16:52 ` Eli Zaretskii
2017-09-18 0:26 ` Paul Eggert
2017-09-18 11:47 ` Fabrice Popineau
2017-09-18 14:46 ` Eli Zaretskii
2017-09-18 0:01 ` Richard Stallman
2017-09-14 19:36 ` Fabrice Popineau
2017-09-14 21:17 ` Andy Moreton
2017-09-15 6:55 ` Fabrice Popineau
2017-09-15 9:12 ` Eli Zaretskii
2017-09-15 15:33 ` Fabrice Popineau
2017-09-15 15:45 ` Eli Zaretskii
2017-09-15 18:15 ` Fabrice Popineau
2017-09-15 19:00 ` Eli Zaretskii
2017-09-15 21:02 ` Fabrice Popineau
2017-09-16 7:45 ` Eli Zaretskii
2017-09-17 7:01 ` Paul Eggert
2017-09-17 14:31 ` Eli Zaretskii
2017-09-17 14:52 ` Philipp Stephani
2017-09-17 22:34 ` Paul Eggert [this message]
2017-09-17 17:07 ` Paul Eggert
2017-09-17 17:14 ` Eli Zaretskii
2017-09-17 18:53 ` Paul Eggert
2017-09-17 19:30 ` Eli Zaretskii
2017-09-17 20:34 ` Paul Eggert
2017-09-18 2:30 ` Eli Zaretskii
2017-09-18 4:52 ` Paul Eggert
2017-09-18 14:41 ` Eli Zaretskii
2017-09-18 17:35 ` Paul Eggert
2017-09-18 17:58 ` Andy Moreton
2017-09-19 9:05 ` Paul Eggert
2017-09-18 18:01 ` Eli Zaretskii
2017-09-17 20:45 ` Paul Eggert
2017-09-16 13:17 ` Andy Moreton
2017-09-16 13:46 ` Eli Zaretskii
2017-09-16 18:57 ` Richard Copley
2017-09-16 19:21 ` Eli Zaretskii
2017-09-15 9:03 ` Eli Zaretskii
2017-09-09 8:49 ` Angelo Graziosi
2017-09-09 10:37 ` Eli Zaretskii
2017-09-09 11:32 ` Angelo Graziosi
2017-09-09 13:28 ` Eli Zaretskii
2017-09-09 13:33 ` Fabrice Popineau
2017-09-09 14:55 ` Angelo Graziosi
2017-09-09 16:37 ` Eli Zaretskii
2017-09-09 18:38 ` Angelo Graziosi
2017-09-09 18:59 ` Eli Zaretskii
2017-09-09 21:29 ` Angelo Graziosi
2017-09-10 14:56 ` Eli Zaretskii
2017-09-10 15:45 ` Angelo Graziosi
2017-09-10 16:02 ` Eli Zaretskii
2017-09-10 18:45 ` Angelo Graziosi
2017-09-10 19:43 ` Eli Zaretskii
2017-09-09 15:40 ` Angelo Graziosi
2017-09-09 16:40 ` Eli Zaretskii
2017-09-09 18:33 ` Fabrice Popineau
2017-09-07 20:20 ` Eli Zaretskii
2017-09-07 21:59 ` Angelo Graziosi
2017-09-08 8:01 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6f175214-6fbe-4ce5-ad6e-a76c1e6e13b0@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=andrewjmoreton@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=fabrice.popineau@centralesupelec.fr \
--cc=p.stephani2@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.