[Issue 10595] New: Using alias this and a hash generates wrong code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 10 07:54:54 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10595

           Summary: Using alias this and a hash generates wrong code
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-07-10 07:54:54 PDT ---
-----
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.

-- 
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