From owner-svn-src-all@FreeBSD.ORG Mon Jul 29 07:05:19 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F213DA81; Mon, 29 Jul 2013 07:05:18 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from zim.MIT.EDU (50-196-151-174-static.hfc.comcastbusiness.net [50.196.151.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CEF7021C6; Mon, 29 Jul 2013 07:05:18 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.7/8.14.2) with ESMTP id r6T75HBB020967; Mon, 29 Jul 2013 00:05:17 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by zim.MIT.EDU (8.14.7/8.14.2/Submit) id r6T75HaW020966; Mon, 29 Jul 2013 00:05:17 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Mon, 29 Jul 2013 00:05:17 -0700 From: David Schultz To: David Chisnall Subject: Re: svn commit: r253215 - head/lib/msun/src Message-ID: <20130729070517.GA3192@zim.MIT.EDU> References: <201307111741.r6BHf5gQ060844@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201307111741.r6BHf5gQ060844@svn.freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jul 2013 07:05:19 -0000 On Thu, Jul 11, 2013, David Chisnall wrote: > +static __inline int > +__inline_isnan(double __x) > +{ > + > + return (__x != __x); > +} > + > +static __inline int > +__inline_isnanf(float __x) > +{ > + > + return (__x != __x); > +} > + > +static __inline int > +__inline_isnanl(long double __x) > +{ > + > + return (__x != __x); > +} This has already been covered at greater length, but I believe this part is incorrect. Relational operators can raise an invalid exception when one of the arguments is a NaN -- even a quiet NaN. Raising an exception is optional in C99 (7.12.14) and required in IEEE-754... in practice, it tends to be platform- and compiler- specific. That is the whole reason the is* macros are defined by the standard in the first place, and also why we didn't use the trivial implementation above. The is* macros are required to not raise an exception. P.S. It would be great if clang implemented the FENV_ACCESS pragma and provided an intrinsic that produced a fast inline isnan() when the pragma is off, and the full, correct one when the pragma is on.