www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5313] New: Struct Arrays Still Compared Bitwise

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

           Summary: Struct Arrays Still Compared Bitwise
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



When comparing structs that contain arrays with different memory addresses, but
the same contents, the comparison fails.

Case 1:

struct StringPair {
    string s1;
    string s2;
}

void main() {
    auto p1 = StringPair("foo".idup, "bar".idup);
    auto p2 = StringPair("foo".idup, "bar".idup);
    assert(p1 == p2);  // Fails
}

Case 2:

struct StringPair {
    uint[] s1;
    uint[] s2;
}

void main() {
    auto p1 = StringPair([1,2], [3,4]);
    auto p2 = StringPair([1,2], [3,4]);
    assert(p1 == p2);  // Fails
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 03 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5313


Simen Kjaeraas <simen.kjaras gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |simen.kjaras gmail.com
         Resolution|                            |DUPLICATE



PST ---
*** 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: -------
Feb 03 2011