March 28, 2023 [Issue 23813] New: DIP1000 can introduce memory corruption in @safe function with typesafe variadics | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23813 Issue ID: 23813 Summary: DIP1000 can introduce memory corruption in @safe function with typesafe variadics Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: kinke@gmx.net With DMD v2.102: ``` auto foo(scope int[] i...) @safe { return () { import core.stdc.stdio; foreach (j; i) printf("%d\n", j); }; } auto bar() @safe { return foo([1, 2, 3, 4, 5, 6]); } void main() { auto dg = bar(); dg(); } ``` This works 'fine' without `-dip1000`. With DIP1000, it prints garbage (array literal allocated on the stack then). It ultimately boils down to the `scope` violation in `foo` not being detected. Related to https://issues.dlang.org/show_bug.cgi?id=23440. -- |
Copyright © 1999-2021 by the D Language Foundation