[Issue 3789] New: comparing a struct with an array member does a bitwise compare

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 9 12:08:24 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3789

           Summary: comparing a struct with an array member does a bitwise
                    compare
           Product: D
           Version: 2.040
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: schveiguy at yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2010-02-09 12:08:23 PST ---
If you have a struct that does not define opEquals, but which contains a member
that defines opEquals, that member's opEquals is called when comparing the
struct.

However, arrays are still bitwise compared.  Example:

struct String
{
    char[] data;
}

void main ()
{
    auto foo = String("foo".dup);
    auto bar = String("foo".dup);

    assert(bar.data == foo.data);
    assert(bar == foo, "oops structs aren't equal");
}

results in the second assert failing.

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


More information about the Digitalmars-d-bugs mailing list