https://issues.dlang.org/show_bug.cgi?id=17892
Issue ID: 17892 Summary: Scope analysis with -dip1000 fails for templated structs Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: per.nord...@gmail.com When struct S { @safe: int[ 128] x; scope ref int front() return { return x[ 0]; } scope int* pointer() return { return &x[ 0]; } } ref int testFront() { S s; return s.front(); // error } int* testPointer() { S s; return s.pointer(); // error } is turned into a template @safe: struct ST( T) { @safe: T[ 128] x; scope ref T front() return { return x[ 0]; } scope T* pointer() return { return &x[ 0]; } } scope analysis (with -dip1000) no longer forbids escaping of reference and pointer as in ref int testFrontT() { ST!int s; return s.front(); // reference to stack element escapes } int* testPointerT() { ST!int s; return s.pointer(); // pointer to stack element escapes } --