This program compiles with no errors: void main() { int[0] foos; foreach (f; foos) {} } But the following 3 ones: int[0] foos; void main() { foreach (f; foos) {} } void main() { static int[0] foos; foreach (f; foos) {} } void main() { __gshared int[0] foos; foreach (f; foos) {} } Crash Optlink with error (DMD 2.060alpha): OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html bug3.obj(bug3) Offset 002C3H Record Type 009D Error 16: Index Range
Very similar to bug 5332, probably another symptom of the same bug.
*** Issue 16129 has been marked as a duplicate of this issue. ***
https://github.com/dlang/dmd/pull/7243
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d4883f2a95a3e7ffe9feb09c688b7a1ef38e45f2 fix Issue 7997 - Optlink issues 'Index Range' error with static zero length array https://github.com/dlang/dmd/commit/4a62e8479c64b371878f23f0e77c154893613aea Merge pull request #7243 from WalterBright/fix7997 fix Issue 7997 - Optlink issues 'Index Range' error with static zero …
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d4883f2a95a3e7ffe9feb09c688b7a1ef38e45f2 fix Issue 7997 - Optlink issues 'Index Range' error with static zero length array https://github.com/dlang/dmd/commit/4a62e8479c64b371878f23f0e77c154893613aea Merge pull request #7243 from WalterBright/fix7997