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.
Comment #1 by kinke — 2023-03-28T15:07:40Z
Oh, the `scope` annotation isn't required, bug happens without `scope` too - probably because of https://github.com/dlang/dmd/pull/14324 ('typesafe variadic parameters should automatically be scope with DIP1000').
Comment #2 by razvan.nitu1305 — 2023-03-29T07:54:19Z
This seems to be an exact dupe of 23440.
*** This issue has been marked as a duplicate of issue 23440 ***
Comment #3 by kinke — 2023-03-29T11:48:49Z
It's not a duplicate, otherwise I wouldn't have filed this, with the cross-link. The underlying cause is most likely the same (undetected `scope` violation), but this specific issue here is about DIP1000 making things worse instead of better.
Comment #4 by robert.schadek — 2024-12-13T19:28:03Z