Bug in tuple comparison?

bearophile bearophileHUGS at lycos.com
Thu Mar 24 10:25:30 PDT 2011


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, this causes some troubles you see in this simpler program:


import std.typecons;
void main() {
    alias Tuple!(int) T;
    const T t = T();
    bool b = t == t;
}


Further reduction:

struct Tuple(T) {
    bool opEquals(R)(R rhs) {
        return false;
    }
}
void main() {
    const Tuple!int t;
    bool b = t == t;
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list