Bug 17117 – [REG2.073] erroneous "escaping reference to local variable"

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-01-24T00:50:00Z
Last change time
2017-06-14T00:38:44Z
Keywords
safe
Assigned to
nobody
Creator
rburners

Comments

Comment #0 by rburners — 2017-01-24T00:50:36Z
auto ref f2(T)(auto ref T t, auto ref T s) { return t; } auto ref f1(T)(auto ref T t, auto ref T s) { return f2(t, s); } unittest { int a = f1(1,2); } This used to work with 2.072. I'm not sure why 2.073 is complaining that. "escaping reference to local variable t"
Comment #1 by john.loughran.colvin — 2017-01-24T10:13:46Z
I suspect this is the same bug, seeing it's the same error in similar circumstances regressed across the same release. This worked fine in 2.072.2 and now fails in 2.073: ref int foo(return ref int s) { return s; } int fail() { int s; return foo(s); // Error: escaping reference to local variable s } int ok() { int s; s = foo(s); return s; } Changed to regression because it's broken correct code.
Comment #2 by andrei — 2017-01-24T13:51:54Z
Robert's code seems to work on https://dpaste.dzfl.pl (2.073), but John's does not. Also, John's code has no ostensible escape, so the bug report stands.
Comment #3 by goxryz — 2017-01-24T17:30:45Z
Both fail on dpaste after enabling the unittest checkbox.
Comment #4 by bugzilla — 2017-01-25T08:07:22Z
I could not duplicate the error with HEAD. But I put in a test case for it anyway. https://github.com/dlang/dmd/pull/6488
Comment #5 by github-bugzilla — 2017-01-28T00:35:45Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/4a4dcf23830e9066a70cb1c381d97306f2bb5bbc fix Issue 17117 - erroneous 'escaping reference to local variable' https://github.com/dlang/dmd/commit/ad85be95ea42be37ccae2ad6133b0b058929fe3e Merge pull request #6488 from WalterBright/fix17117 fix Issue 17117 - erroneous 'escaping reference to local variable'
Comment #6 by mk — 2017-01-28T01:27:23Z
Walter, can you fix this in 2.073 too ?
Comment #7 by github-bugzilla — 2017-02-24T20:34:25Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/4a4dcf23830e9066a70cb1c381d97306f2bb5bbc fix Issue 17117 - erroneous 'escaping reference to local variable' https://github.com/dlang/dmd/commit/ad85be95ea42be37ccae2ad6133b0b058929fe3e Merge pull request #6488 from WalterBright/fix17117
Comment #8 by github-bugzilla — 2017-03-22T12:21:25Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/4a4dcf23830e9066a70cb1c381d97306f2bb5bbc fix Issue 17117 - erroneous 'escaping reference to local variable' https://github.com/dlang/dmd/commit/ad85be95ea42be37ccae2ad6133b0b058929fe3e Merge pull request #6488 from WalterBright/fix17117
Comment #9 by mk — 2017-06-14T00:38:44Z