Bug 10595 – Using alias this and a hash generates wrong code
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-10T07:54:00Z
Last change time
2013-09-22T22:14:18Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2013-07-10T07:54:54Z
-----
struct S
{
bool b = true;
bool test()
{
if (!b) // note: must be a check, not 'return b;'
return false;
return true;
}
}
struct Wrap
{
int i;
alias i this;
S s;
}
void main()
{
{
Wrap[int] wrap;
wrap[0] = Wrap();
wrap[0].i = 0;
assert(wrap[0].s.test()); // ok
}
{
Wrap[int] wrap;
wrap[0] = Wrap();
wrap[0] = 0; // note: using 'alias this' to assign
assert(wrap[0].s.test()); // failure
}
}
-----
It doesn't appear to be a regression.