[Issue 13420] double.nan unusable as AA key

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Sep 3 22:24:32 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13420

--- Comment #5 from Vladimir Panteleev <thecybershadow at gmail.com> ---
(In reply to hsteoh from comment #3)
> In this sense, I argue that existing code that uses floating-point AA keys
> is already broken -- recently, for example, there was a PR to make aa[0.0]
> the same thing as aa[-0.0]. Logically this may make sense, but then you have
> to deal with NaN being never equal to itself, and there's no way a generic
> AA implementation can deal with this satisfactorily (at least, not without
> breaking the IEEE floating-point semantics).
> 
> The only sensible solution I can see is to treat floating-point keys as
> their binary representations instead of their logical meaning, which means
> that aa[0.0] and aa[-0.0] should be distinct. Which would mean reopening the
> bug associated with the PR that treated 0.0 as equal to -0.0.

This is the behavior that my code was relying on. My project[1] was building a
constant pool, and was relying on AAs doing bitwise hashing/comparison for
doubles.

Of course, the work around was simple, but that doesn't change that this
regression broke code that's out there.

I'm not going to argue which behavior is more correct or more useful, just
pointing out that the old behavior did have a valid use case, and certainly
wasn't broken.

  [1]: https://github.com/CyberShadow/RABCDAsm

--


More information about the Digitalmars-d-bugs mailing list