https://issues.dlang.org/show_bug.cgi?id=20401
Issue ID: 20401
Summary: ref variable copied before return
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Test case:
```
void main()
{
int i;
assert(&passthrough(i) == &i);
}
ref int passthrough(return ref int i)
{
return get().flag ? i : i;
}
S get() { return S(); }
struct S
{
bool flag;
~this(){}
}
```
Assertion fails. `passthrough` should return `i` without making a copy of it.
--