https://run.dlang.io/is/diWtCa
---------------------------------------------------------
import std;
@safe auto test(scope int* x)
{
int y = 69;
x = &y; //bad
return x;
}
void main()
{
auto y = test(null);
writeln("Would you like some stack memory?");
writeln(*y);
}
---------------------------------------------------------
Currently compiles, whereas replacing auto with int* will make the compiler complain about a scope variable being returned (as it should).
If we preemptively declare test as:
auto test(return scope* x) {...} then the compiler notices the assignment of a stack reference.
Comment #1 by dlang-bot — 2019-08-07T09:39:59Z
@RazvanN7 created dlang/dmd pull request #10285 "Fix Issue 20108 - -dip1000 defeated by auto" fixing this issue:
- Fix Issue 20108 - -dip1000 defeated by auto
https://github.com/dlang/dmd/pull/10285
Comment #2 by dlang-bot — 2019-08-07T13:19:18Z
dlang/dmd pull request #10285 "Fix Issue 20108 - -dip1000 defeated by auto" was merged into stable:
- 2802c9990d925125fd1046fd43a43a387bfa62fb by RazvanN7:
Fix Issue 20108 - -dip1000 defeated by auto
- e354b2f78f68148daa27b3a8aef08c650acb8a8c by RazvanN7:
Fix Issue 20108 - -dip1000 defeated by auto
https://github.com/dlang/dmd/pull/10285