[Issue 10525] New: Struct as key in Associative array ignores value semantics
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 2 02:06:33 PDT 2013
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: nobody at puremagic.com
ReportedBy: michal.minich at gmail.com
--- Comment #0 from Michal Minich <michal.minich at gmail.com> 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: -------
More information about the Digitalmars-d-bugs
mailing list