https://issues.dlang.org/show_bug.cgi?id=19966
Issue ID: 19966 Summary: [DIP1000] DIP1000 with a template behaves differently Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: safe Severity: critical Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: d...@me.com The following code compile successfully with DIP1000 enabled: struct Foo() { int* bar; int* foo() @safe return { return bar; } } int* a; void main() @safe { Foo!() f; a = f.foo; } But if `Foo` is not a template it fails to compile, complaining that the return value of `foo` outlives `f`. I think there are two errors here: 1. `Foo` as a template and as a non-template struct behaves differently 2. I think the above code is actually valid because it's not provable that `foo` escapes a pointer to the internal state of `Foo` --