[Issue 20475] New: Struct of static array of strings is bitwise-compared instead of member-wise

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 31 17:30:55 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20475

          Issue ID: 20475
           Summary: Struct of static array of strings is bitwise-compared
                    instead of member-wise
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: hsteoh at quickfur.ath.cx

Code:
------
struct S {
        string[2] x;
}
void main() {
        auto s = S(["a", "b"]);
        auto t = S(["a", ""]);
        t.x[1] ~= "b";
        assert(s == t);
}
------

Expected result: assertion should pass.

Actual result: assertion fails.

Looking at the disassembly, it appears that the struct comparison with == is
implemented as a bitwise comparison, which is wrong because 'string' is not a
POD and therefore the static array member ought to be compared member-wise
rather that bitwise.

--


More information about the Digitalmars-d-bugs mailing list