← Back to index
|
Original Bugzilla link
Bug 23117 – crash in @safe code after CTFE
Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-05-17T06:40:49Z
Last change time
2024-12-13T19:22:51Z
Assigned to
No Owner
Creator
Susan
Moved to GitHub: dmd#20105 →
Comments
Comment #0
by su+dlangissues — 2022-05-17T06:40:49Z
the following code crashes. void main() @safe { enum crash = foo([1]); import std.stdio : writeln; writeln(crash); } auto foo(in int[] r) @safe nothrow pure { import std.algorithm : map; import std.range : enumerate; return r.map!(x => enumerate(r)); }
Comment #1
by dkorpel — 2022-05-17T10:28:50Z
Reduced to remove Phobos imports: ``` @safe: auto crash = foo([10]); void main() { assert(crash.front.front == 10); } struct Map(alias f) { int[] range; auto front() { return f(range[0]); } } struct Enumerate { int[] range; int front() { return range[0]; } } auto foo(int[] r) { return Map!(x => Enumerate(r))(r); } ```
Comment #2
by dkorpel — 2022-05-17T10:33:18Z
Reduced some more: ``` @safe: auto crash = foo(10); void main() { assert(crash.front == 10); } struct Map(alias f) { int front() { return f(); } } auto foo(int r) { return Map!(() => r)(); } ```
Comment #3
by robert.schadek — 2024-12-13T19:22:51Z
THIS ISSUE HAS BEEN MOVED TO GITHUB
https://github.com/dlang/dmd/issues/20105
DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB