www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11238] New: Codegen error when this is a ref parameter to the method

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11238

           Summary: Codegen error when this is a ref parameter to the
                    method
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: aliloko gmail.com



When executing the program:

struct A
{
    void f()
    {
        g(this);
    }

    void g(ref A res)
    {
        res.m = [m[1], m[0]]; // swap
    }

    int[2] m;
}

void main()
{
    A a;
    a.m[0] = 4;
    a.m[1] = 6;
    writefln("%s,%s", a.m[0], a.m[1]);
    a.f();
    writefln("%s,%s", a.m[0], a.m[1]);
    a.f();
    writefln("%s,%s", a.m[0], a.m[1]);
}

Output is:
4,6
6,6
6,6


But I'm expecting this, that DMD 2.062 does output:
4,6
6,4
4,6


DMD 2.063, DMD 2.063.2 and DMD 2.064 beta all have this bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 12 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11238


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



18:06:38 PDT ---
Reduced, I think this bug is unrelated to ref'ness:

-----
import std.algorithm;
import std.stdio;

void main()
{
    int[2] arr;

    arr[0] = 1;
    arr[1] = 2;

    writeln(arr);

    arr = [arr[1], arr[0]];
    // swap(arr[1], arr[0]);  // workaround

    writeln(arr);
}
-----

$ dmd -run test.d
 [1, 2]
 [2, 2]
Versions older than 2.063 don't seem to have this issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11238


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code
         OS/Version|Windows                     |All



https://github.com/D-Programming-Language/dmd/pull/2682
 Versions older than 2.063 don't seem to have this issue.
The cause was the fix of bug 2356. https://github.com/D-Programming-Language/dmd/pull/2682 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11238




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b033705cb88b83de5bcad93ef3fbe9966c347aa7
fix Issue 11238 - Codegen error when this is a ref parameter to the method

Revert a part of the fix for issue 2356, to avoid aliasing issue.

https://github.com/D-Programming-Language/dmd/commit/7d3b38e87c3722df34d8e23762b9b97b8945c0e5


[REG2.063] Issue 11238 - Codegen error when this is a ref parameter to the
method

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11238




Commit pushed to 2.064 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f2c996a0220230762677a665842f402f576499c5


[REG2.063] Issue 11238 - Codegen error when this is a ref parameter to the
method

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 20 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11238


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 20 2013