From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Suspicious warning in W64 build Date: Sun, 17 Sep 2017 15:34:02 -0700 Organization: UCLA Computer Science Department Message-ID: <6f175214-6fbe-4ce5-ad6e-a76c1e6e13b0@cs.ucla.edu> References: <1017454172.910810.1504618695244@mail.libero.it> <83tw0cwcle.fsf@gnu.org> <83h8wcw3td.fsf@gnu.org> <83377vx3d0.fsf@gnu.org> <83ingnq01t.fsf@gnu.org> <83fubrpxsv.fsf@gnu.org> <83r2v9masw.fsf@gnu.org> <86a81xrndl.fsf@gmail.com> <83a81wmijy.fsf@gnu.org> <83vakkklto.fsf@gnu.org> <83poarlrcj.fsf@gnu.org> <83h8w3krx1.fsf@gnu.org> <83bmm9jt23.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3DD437BE0915837E5200DBCA" X-Trace: blaine.gmane.org 1505687668 7618 195.159.176.226 (17 Sep 2017 22:34:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 17 Sep 2017 22:34:28 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 Cc: fabrice.popineau@centralesupelec.fr, andrewjmoreton@gmail.com, emacs-devel@gnu.org To: Philipp Stephani , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 18 00:34:21 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dti8r-0001cx-Cz for ged-emacs-devel@m.gmane.org; Mon, 18 Sep 2017 00:34:21 +0200 Original-Received: from localhost ([::1]:33857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dti8x-0000dr-5o for ged-emacs-devel@m.gmane.org; Sun, 17 Sep 2017 18:34:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dti8o-0000dX-11 for emacs-devel@gnu.org; Sun, 17 Sep 2017 18:34:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dti8k-0001t3-8X for emacs-devel@gnu.org; Sun, 17 Sep 2017 18:34:18 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dti8f-0001qe-Nz; Sun, 17 Sep 2017 18:34:09 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 122FB160D7D; Sun, 17 Sep 2017 15:34:07 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id kypOnXygUZ2e; Sun, 17 Sep 2017 15:34:02 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AEA61160D82; Sun, 17 Sep 2017 15:34:02 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id WpCJXQDG4Rrf; Sun, 17 Sep 2017 15:34:02 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.154.18.85]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 80F41160D33; Sun, 17 Sep 2017 15:34:02 -0700 (PDT) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218437 Archived-At: This is a multi-part message in MIME format. --------------3DD437BE0915837E5200DBCA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Philipp Stephani wrote: > How about rewriting the function body like this: Yes, that should work and avoids either UNINIT or some other pacifier. Al= so,=20 while looking at it, I noticed an actual bug in min and max, which is a p= lus. I=20 installed the attached into emacs-26, to fix both problems. --------------3DD437BE0915837E5200DBCA Content-Type: text/x-patch; name="0001-Fix-bug-with-min-and-max-and-NaNs.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Fix-bug-with-min-and-max-and-NaNs.patch" =46rom 5f28f0db73c03b98b27e04a458ebb209b5d9acde Mon Sep 17 00:00:00 2001 From: Paul Eggert 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 =3D args[0]; /* pacify GCC */ - for (ptrdiff_t argnum =3D 0; argnum < nargs; argnum++) + Lisp_Object accum =3D args[0]; + CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (accum); + for (ptrdiff_t argnum =3D 1; argnum < nargs; argnum++) { Lisp_Object val =3D args[argnum]; CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val); - if (argnum =3D=3D 0 || !NILP (arithcompare (val, accum, comparison= ))) + if (!NILP (arithcompare (val, accum, comparison))) accum =3D 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 (=3D 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)))) =20 ;; Bool vector tests. Compactly represent bool vectors as hex ;; strings. --=20 2.7.4 --------------3DD437BE0915837E5200DBCA--