From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13855 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Markus Wichmann Newsgroups: gmane.linux.lib.musl.general Subject: Re: FE Exception triggered by comparison Date: Sun, 24 Feb 2019 18:12:50 +0100 Message-ID: <20190224171250.GA28106@voyager> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="184649"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-13871-gllmg-musl=m.gmane.org@lists.openwall.com Sun Feb 24 18:14:10 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1gxxLp-000lsB-Iw for gllmg-musl@m.gmane.org; Sun, 24 Feb 2019 18:14:05 +0100 Original-Received: (qmail 23977 invoked by uid 550); 24 Feb 2019 17:14:02 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 23959 invoked from network); 24 Feb 2019 17:14:02 -0000 Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:1wW0E8S9nGIkLRSkfECjQ6mYpoajt4hOMi4QfLtPpPgV/Oycb/7 PYQ+zlvZW9B3sTpqamcW0HDgMsEDzi622OndpioolX1vDqkwR+Pa3ZGsDrLMXG+gz1/te4u JkFG1izRW2rluW0ciPkqxwfrc1X24wvwDuZ/Njegl6TwIofTcgh91i7vI4hwAOBjMR5dQOD 9IHqxgeqiYFZUq3dm+qDw== X-UI-Out-Filterresults: notjunk:1;V03:K0:LGxrT25D19A=:y8h+E8gIQCkVst5TwMR0P/ eRNgKtn6F0t3dVapQoqTjxMJol3WaTyjC2d9Ju+ovlGFvfwWLEkJ4g3U1mRswWWsH/7cdm+36 EMl+sRO0PQXX9KisN5q2CH3wpsPK593SglhW7fhxl/2W4BUmMwZWIHgdfDOjjMDSEqf4vZK5l Y41SR75JRUzAhIbmRULEZX3i9QTu6UmhWoTDYr/b2Imfu9xYW+2w10+yYJJEZO7c5ZqEgcZcf m5g4d5MWEITD6QKC3Dy44CdAzZxiSdcnO/50O3khtDrnhbOnx5kZjMy6wqHKVmRaGMydtjC7p AsJj7Ib0JWmQ2cP33dDWXA/xgPhuuUyb1VlQ4yAMuAIqCVfqz6wx1GZjGdxzcdmQBoCitUpOU o4pxqQiPcCCeeLzdfb9AndEheIbLrAS3REcSsTBxGgTovz7+gGqkN5nogIFTn7BF0UWncFQX/ rzoVOr3rsWwF70z5m68Ex5sSFuZ5A/DCvB/fNd56gmmyK//pX94SSCXuMPcQghEC55qogt52a zWOk4Oi84kCmlGk3R2h4cMO161UNx1IO4gdQT4ybSJQBP9nDBPp6oOHGbOLy5IsWCy/U8h7nf 1WlXOlnXMSQQwa3FPeZdIbpp5+1twauIopycdfD/10wpEPlCm/NPSUa7cWDjeSt4xP2nA/iz2 EfoH766hzZV94LdZL/oz9dU5ElLrt/xq2OZc0iBNssYkkVB024tC/ozJxEf44ww0cqWiC4HNB Mqyr8lD8sVqG97FwDD4XDg4m5r5GEk/+6N+OuAO9TH/n9W57C0+43Ptws/ktI8kA7DdTbOro Xref: news.gmane.org gmane.linux.lib.musl.general:13855 Archived-At: On Mon, Feb 25, 2019 at 12:28:20AM +1100, Damian McGuckin wrote: > > What comparison of FP numbers trigger invalid operation exceptions? > > Does a comparison like > > if (x != x) > { > /* get to here if x == NaN * > } > > which tests for a NaN cause an invalid operation if given an sNaN? > > Even reading the standard numerous times and I am not any wiser. > > Thanks - Damian > In cases like these, I like to read the documentation of an implementation, under the assumption that it is conforming. One implementation of IEE 754 general considered to be conforming is the x87 instruction set. And AMD's documentation of the same (AMD64 Architecture Programmer's Manual, Volume 5, Order No. 26569) says about the FCOM instruction, that it will generate an invalid-operation exception if any source operand was a NaN. Same for FCOMI and FICOM. Only difference for FUCOM and FUCOMI is that those only raise IE for an SNaN. Cross-checking with volume 4 shows that the SSE FP compare instructions all raise IE in case of SNan source operand, and in case of "Undefined operation". No idea what the latter is supposed to mean in context, unless it means that QNaNs trigger it, too. So yes, it appears at least in a PC, comparison with NaN raises IE. Ciao, Markus