[Issue 20108] New: -dip1000 defeated by auto
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 5 02:10:22 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20108
Issue ID: 20108
Summary: -dip1000 defeated by auto
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: maxhaton at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list