Bug 23391 – [Reg 2.098.1] Segmentation fault with static foreach + range + inout

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-10-06T13:06:28Z
Last change time
2023-01-01T06:25:11Z
Keywords
ice-on-valid-code, pull
Assigned to
No Owner
Creator
james.gray

Comments

Comment #0 by james.gray — 2022-10-06T13:06:28Z
The following code (reduced by Mayonix on discord) causes the compiler to crash: ```d struct MyTuple { string s; } inout(string) myfront(inout(string)[] a) { return a[0]; } MyTuple[] myarray(MyZip r) { MyTuple[] result; foreach (e; r) result ~= e; return result; } struct MyZip { bool empty = false; MyTuple front() { return MyTuple([""].myfront); } void popFront() { empty = true; } } static foreach(t; MyZip().myarray) {} ```
Comment #1 by dlang-bot — 2022-12-19T06:10:49Z
@ibuclaw created dlang/dmd pull request #14719 "fix Issue 23391 - [Reg 2.098.1] Segmentation fault with static foreach + range + inout" fixing this issue: - fix Issue 23391 - [Reg 2.098.1] Segmentation fault with static foreach + range + inout https://github.com/dlang/dmd/pull/14719
Comment #2 by dlang-bot — 2022-12-19T12:14:47Z
dlang/dmd pull request #14719 "fix Issue 23391 - [Reg 2.098.1] Segmentation fault with static foreach + range + inout" was merged into stable: - e02ffec5e0bdf3e0a5f133df5defe20a9bc94094 by Iain Buclaw: fix Issue 23391 - [Reg 2.098.1] Segmentation fault with static foreach + range + inout https://github.com/dlang/dmd/pull/14719
Comment #3 by dlang-bot — 2023-01-01T06:25:11Z
dlang/dmd pull request #14765 "merge stable" was merged into master: - b953c592c168ef7fce564f9d8587e67c623707a4 by Iain Buclaw: fix Issue 23391 - [Reg 2.098.1] Segmentation fault with static foreach + range + inout https://github.com/dlang/dmd/pull/14765