Should this be correct behaviour?

Janice Caron caron800 at googlemail.com
Thu Nov 29 05:39:48 PST 2007


Should this be correct behaviour?

    float[] f = new float[1];
    float[] g = f.dup;
    assert(f == g); /* Passes */
    assert(f[0] == g[0]); /* Fails */

Certainly it is correct for the second assert to fail, because f[0]
and g[0] both contain nan, and as we all know, (nan != nan).
Essentially, the second assert (correctly) fails because the elements
have not been initialised, and so we can't do the compare.

My question is, shouldn't the first assert also fail?

Put another way, how can two arrays be considered equal, if their
elements are not considered equal?

I realise that everything is behaving according to spec. But is it sensible?



More information about the Digitalmars-d mailing list