[Issue 5313] New: Struct Arrays Still Compared Bitwise
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 3 08:13:15 PST 2010
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: nobody at puremagic.com
ReportedBy: dsimcha at yahoo.com
--- Comment #0 from David Simcha <dsimcha at 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: -------
More information about the Digitalmars-d-bugs
mailing list