https://issues.dlang.org/show_bug.cgi?id=24750
Issue ID: 24750
Summary: escaping sliced stack arrays not detected
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Jonathan Davis reports:
int[] foo()
{
int[3] arr = [1,2,3];
return arr[]; // returning `arr[]` escapes a reference to local variable
`arr`
}
whereas:
int[] foo()
{
int[3] arr = [1,2,3];
int[] slice = arr[];
return slice;
}
compiles without complaint.
--