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.