[cfe-dev] signbit returns false for negative NaN
victor.zverovich at gmail.com
victor.zverovich at gmail.com
Fri Jun 6 12:21:20 PDT 2014
I've checked and the same happens with the signbit macro.
Victor
On Fri, Jun 6, 2014 at 11:56 AM, Aaron Ballman <aaron at aaronballman.com>
wrote:
> On Fri, Jun 6, 2014 at 2:51 PM, victor.zverovich at gmail.com
> <victor.zverovich at gmail.com> wrote:
> > Hello,
> >
> > When compiling with a recent version of Clang, the following code
> >
> > std::signbit(-std::numeric_limits<double>::quiet_NaN())
> >
> > returns true with optimizations disabled and false with optimizations
> > enabled. Other compilers like GCC and older versions of Clang always
> return
> > true as expected. Is it a bug or a feature?
> >
> > I'm using Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn).
>
> I believe this is likely a bug. std::signbit is defined to behave the
> same as the C macro of the same name, which has the footnote, "The
> signbit macro reports the sign of all values, including infinities,
> zeros, and NaNs. If zero is unsigned, it is treated as positive."
>
> ~Aaron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140606/e06938bf/attachment.html>
More information about the cfe-dev
mailing list