[Issue 13420] double.nan unusable as AA key

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Sep 22 04:21:19 PDT 2014


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

--- Comment #9 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Vladimir Panteleev from comment #8)
> (In reply to Steven Schveighoffer from comment #7)
> > every access using every key type must be checked
> 
> Only insertion, and only in non-release mode.

Well, if we do it only on insertion, that may work. Actually that's a pretty
good idea, because you are already incurring the cost of adding a node,
potentially rehashing, doing a quick comparison of a key to itself isn't going
to be significant. And you only pay once per element in the AA, not once per
access. But I think "only in non-release mode" is not possible -- AA's are (at
least currently) runtime based, so you would need a non-release version of
druntime to get it to catch your error.

Even if they were switched to a library template, you would potentially have
already-compiled AA inside phobos which would be release mode. We could
potentially just ensure that X[float] never occurs in phobos.

But are we fixing a problem that is not widespread or significant? I still am
skeptical that there are many AAs that depend on nan for a key, and any which
did so is fundamentally flawed and depending on incorrect compare
implementation.

--


More information about the Digitalmars-d-bugs mailing list