Bug 9568 – [64bit] wrong code for scope(exit)

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-22T00:59:00Z
Last change time
2015-06-09T05:11:47Z
Keywords
wrong-code
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2013-02-22T00:59:55Z
64 bit only. Originally found in D1, but also applies to D2. ------ int bug9568(ref string x) { string y = x; scope (success) { assert(x == y); } return 0; } void main() { string e = "xxx"; int result = bug9568(e); assert( ! result ); // fails }
Comment #1 by clugdbug — 2013-02-22T01:33:13Z
Slightly clearer test case, which works unaltered on D1 as well. It is necessary for both x and y to be passed as parameters (this was happening with x==y in my first test case, which was making a call to the runtime). ------ void use9568(char [] m, char [] p) {} int bug9568(ref char[] x) { char[] y = x; scope (success) use9568(x,y); return 7; } void main() { char[] e = null; assert( bug9568(e) == 7 ); }
Comment #2 by clugdbug — 2013-02-22T01:42:18Z
And it's a regression (at least on D1, haven't checked old versions of D2). This code worked in 1.074 and 1.075, fails in 1.076.
Comment #3 by clugdbug — 2013-02-22T02:55:30Z
Also applies to scope(exit), which is more important because it is more commonly used.
Comment #4 by clugdbug — 2013-02-22T03:40:06Z
Even further reduced. Reference parameter is not necessary. I also replaced the scope(exit) with a try{}finally{} block, which is what happens in the front-end. ================== void use9568(char [] x, char [] y) {} int bug9568() { try return 7; finally use9568(null,null); } void main() { assert( bug9568() == 7 ); }
Comment #5 by github-bugzilla — 2013-02-24T23:48:07Z
Comment #6 by bugzilla — 2013-02-24T23:50:45Z
Comment #7 by github-bugzilla — 2013-02-25T01:15:40Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/adf20ce10fcfec68cf74cad7aa110c3a314d45f7 fix Issue 9568 - [64bit] wrong code for scope(exit) https://github.com/D-Programming-Language/dmd/commit/2352d02ec79eef3a19dd3f743088b382a239f17e Merge pull request #1689 from WalterBright/fix9568 fix Issue 9568 - [64bit] wrong code for scope(exit)
Comment #8 by github-bugzilla — 2013-02-25T10:29:05Z
Commits pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f50e8f5dbd91aae4fb3beaa900b966c2938348d1 fix Issue 9568 - [64bit] wrong code for scope(exit) https://github.com/D-Programming-Language/dmd/commit/1cbce51be1e5a686f53e4c81f686d6b728dbacbf Merge pull request #1690 from donc/mergeBug9568 D1: fix Issue 9568 - [64bit] wrong code for scope(exit)
Comment #9 by github-bugzilla — 2013-02-25T10:38:44Z