|
Boost : |
Subject: Re: [boost] [ICL] #6853: boost::icl::contains(NaN) returns true
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2012-05-04 16:10:33
Jeffrey Lee Hellrung, Jr. wrote:
> > On Fri, May 04, 2012 at 11:48:30AM -0700, Jeffrey Lee Hellrung, Jr. wrote:
> > > On Fri, May 4, 2012 at 8:14 AM, Andrew Hundt <ahundt_at_[hidden]>
> wrote:
> > > How well does std::set/std::map interact with NaN when floating point
> > > types are used as keys?
> >
> > Undefinedly, most usually explodedly.
> >
> > For libraries that have sanity checks on the comparator, hard asserts.
> > For the rest (or NDEBUG), amusing loss of elements and general
> > malfunction.
> >
>
> Then it seems reasonable to me for ICL to also opt not to support NaN's in
> favor of a simpler implementation, better performance, etc.
I want to add that for recent gcc (at least for gcc 4.5.2), even the built-in "isnan" functions stops working when the compiler flag "-ffast-math" is used. That broke some of my code, and I had to debug quite a while before I found the reason. It took me so long since I couldn't believe that the built-in "isnan" would go wrong. My conclusion from this is that NaN can't be used portably, so there is no point for Boost.ICL to try to support it.
Regards,
Thomas
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk