Bug 7342 – Structs don't call the right opEquals on contained arrays
Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-01-21T15:52:00Z
Last change time
2012-01-22T05:39:36Z
Keywords
wrong-code
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-01-21T15:52:25Z
This assert fires, but this is wrong:
const struct Foo { int[] a; }
void main() {
Foo f1 = Foo([1, 2]);
Foo f2 = Foo([1] ~ 2);
assert(f1 !is f2); // OK
assert(f1 == f2); // AssertError
}
It's a source of bugs, like:
import std.stdio;
const struct Foo { int[] a; }
void main() {
int[const Foo] aa;
aa[Foo([1, 2])] = 1;
aa[Foo([1] ~ [2])] = 2;
writeln(aa);
}
[const(Foo)([1, 2]):1, const(Foo)([1, 2]):2]
Please fix this. I have set the "major" Severity (almost "Critical") because this causes some of the worst bugs I have had in single-threaded D code.