www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7342] New: structs don't call the right opEquals on contained arrays

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7342

           Summary: structs don't call the right opEquals on contained
                    arrays
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 21 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7342


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE



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 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 22 2012