[Issue 24750] New: escaping sliced stack arrays not detected
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Sep 7 21:43:13 UTC 2024
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: nobody at puremagic.com
Reporter: bugzilla at digitalmars.com
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.
--
More information about the Digitalmars-d-bugs
mailing list