December 31, 2019 [Issue 20475] New: Struct of static array of strings is bitwise-compared instead of member-wise | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: hsteoh@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. -- |
Copyright © 1999-2021 by the D Language Foundation