Bug 5313 – Struct Arrays Still Compared Bitwise

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-12-03T08:11:00Z
Last change time
2011-02-03T04:40:41Z
Keywords
wrong-code
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2010-12-03T08:11:41Z
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 }
Comment #1 by simen.kjaras — 2011-02-03T04:40:41Z
*** This issue has been marked as a duplicate of issue 3789 ***