Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Jul 2013 00:05:17 -0700
From:      David Schultz <das@FreeBSD.ORG>
To:        David Chisnall <theraven@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r253215 - head/lib/msun/src
Message-ID:  <20130729070517.GA3192@zim.MIT.EDU>
In-Reply-To: <201307111741.r6BHf5gQ060844@svn.freebsd.org>
References:  <201307111741.r6BHf5gQ060844@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130729070517.GA3192>