Bug 11238 – Codegen error when this is a ref parameter to the method

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-12T17:24:00Z
Last change time
2013-10-20T10:21:06Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
aliloko

Comments

Comment #0 by aliloko — 2013-10-12T17:24:30Z
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.
Comment #1 by andrej.mitrovich — 2013-10-12T18:06:38Z
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.
Comment #2 by k.hara.pg — 2013-10-19T10:01:08Z
https://github.com/D-Programming-Language/dmd/pull/2682(In reply to comment #1) > 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
Comment #3 by github-bugzilla — 2013-10-20T10:20:10Z
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 Merge pull request #2682 from 9rnsr/fix11238 [REG2.063] Issue 11238 - Codegen error when this is a ref parameter to the method
Comment #4 by github-bugzilla — 2013-10-20T10:20:42Z
Commit pushed to 2.064 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f2c996a0220230762677a665842f402f576499c5 Merge pull request #2682 from 9rnsr/fix11238 [REG2.063] Issue 11238 - Codegen error when this is a ref parameter to the method