Bug in tuple comparison?
Jonathan M Davis
jmdavisProg at gmx.com
Thu Mar 24 11:14:14 PDT 2011
> On 2011-03-24 18:25:30 +0100, bearophile said:
> > Magnus Lie Hetland:
> >> I guess this is getting old by now ... but I've come across yet another
> >> bug :->
> >
> > The out(result) turns the result into a const,
>
> Riiight! Yes, I've seen that it's const, and (naughtily) cast away the
> constness (without modifying anything) in some cases. It didn't occur
> to me that that was the problem here. :) (In my original program, I
> didn't notice that I had gotten one of the values from outside the
> out-block, while the other was from the result. I guess I was "primed"
> to think that that wasn't the problem ;)
>
> So the issue, then, I take it, is that you *can* compare a non-const
> tuple to a const-tuple, but you *cannot* compare a const-tuple to a
> non-const tuple (as per casting rules)?
>
> Makes sense. Would have been nice with a slightly more obvious error
> message, but I guess that's always a problem with templates in any form
> ;)
>
> Aanyway -- glad the bug was just in my code/brain :D Thanks for the help,
If you const-ness affects comparison, that _is_ a bug. Currently, a struct's
opEquals should take a "const ref Type rhs" and Tuple isn't doing that. So,
that's a bug in Tuple. There are a number of const-correctness bugs in
druntime and Phobos though - the mother of them all being
http://d.puremagic.com/issues/show_bug.cgi?id=1824
Regardless, this _is_ a bug.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list