struct A
{
int[] b;
}
inout(int[]) f1(ref inout A);
void f2(inout A src)
{
inout A c=src;
inout(int[])[] a;
a~=f1(c);
}
onlineapp.d(10): Error: copying f1(c) into allocated memory escapes a reference to local variable c
Comment #1 by slavo5150 — 2019-09-21T08:16:12Z
This appears to be the same as Issue 17927 and Issue 20149
Comment #2 by razvan.nitu1305 — 2022-03-24T09:58:22Z
I cannot reproduce this with the most recent master. Please reopen if you are able to reproduce.
Comment #3 by dkorpel — 2022-03-24T11:27:30Z
This is 'fixed' because `inout` doesn't imply `return` anymore (issue 22027).
If you change the function signature to this:
```
inout(int[]) f1(return ref inout A);
```
The error is back when you pass -preview=dip1000, but it's valid, because the return value can be a pointer to the struct A which is allocated on the stack in f2, and you can't store a stack pointer in a dynamic array.
If f1 becomes this (which is likely what the function should be, judging by the types):
```
inout(int[]) f1(ref return scope inout A);
```
Then there's no error, which is correct because local var c is not `scope`. Either way, it's fixed now.