D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7342 - Structs don't call the right opEquals on contained arrays
Summary: Structs don't call the right opEquals on contained arrays
Status: RESOLVED DUPLICATE of issue 3789
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 major
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2012-01-21 15:52 UTC by bearophile_hugs
Modified: 2012-01-22 05:39 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2012-01-21 15:52:25 UTC
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.
Comment 1 Kenji Hara 2012-01-22 05:39:36 UTC
This is part of 3789.
See http://d.puremagic.com/issues/show_bug.cgi?id=3789#c11

*** This issue has been marked as a duplicate of issue 3789 ***