You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CODE:
------snip------
struct S {
int[] data;
}
void main() {
auto s = S([1,2,3]);
auto t = S([1,2,3]);
auto u = S([1,2,4]);
assert(s == t); assert(s != u); assert(typeid(s).compare(&s, &t) == 0); // FAILS assert(typeid(s).compare(&s, &u) != 0);
}
------snip------
Since S doesn't define opEquals or opCmp, the typeinfo's .compare is just the default provided by DMD. However, it uses bitwise comparison, whereas == uses field-wise comparison.
The text was updated successfully, but these errors were encountered:
hsteoh reported this on 2013-07-09T13:48:31Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=10588
Description
CODE: ------snip------ struct S { int[] data; } void main() { auto s = S([1,2,3]); auto t = S([1,2,3]); auto u = S([1,2,4]); assert(s == t); assert(s != u); assert(typeid(s).compare(&s, &t) == 0); // FAILS assert(typeid(s).compare(&s, &u) != 0); } ------snip------ Since S doesn't define opEquals or opCmp, the typeinfo's .compare is just the default provided by DMD. However, it uses bitwise comparison, whereas == uses field-wise comparison.The text was updated successfully, but these errors were encountered: