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
This appears to be the same as Issue 17927 and Issue 20149
I cannot reproduce this with the most recent master. Please reopen if you are able to reproduce.
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.