[Issue 20401] New: ref variable copied before return
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 17 01:14:21 UTC 2019
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: nobody at puremagic.com
Reporter: sahmi.soulaimane at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list