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: nob...@puremagic.com
        ReportedBy: dsim...@yahoo.com


--- Comment #0 from David Simcha <dsim...@yahoo.com> 2010-12-03 08:11:41 PST ---
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: -------

Reply via email to