http://d.puremagic.com/issues/show_bug.cgi?id=10525
Summary: Struct as key in Associative array ignores value
semantics
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Michal Minich <[email protected]> 2013-07-02 02:06:31
PDT ---
DMD 2.063.2
struct S { char[] str; }
void main ()
{
auto s1 = S(cast(char[])"abc");
auto s2 = S(cast(char[])"Xbc");
// indirect members in structs are compared by value
assert (s1 != s2); // ok, structs are compared not equal
s2.str[0] = 'a';
assert (s1 == s2); // ok, structs are compared equal
// not so in AA
auto aa = [s1 : 1];
auto s1aa = s1 in aa;
assert (s1aa);
auto s2aa = s2 in aa;
assert (s2aa); // fails, but should pass
// s2 should be found in aa the same way as s1
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------