Bug 9577 – Crash on static array of function literals

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-23T06:59:00Z
Last change time
2013-11-22T22:18:09Z
Keywords
ice, pull
Assigned to
nobody
Creator
argcc

Comments

Comment #0 by argcc — 2013-02-23T06:59:14Z
//DMD32 D Compiler v2.062 just crash on this without any messages: import std.stdio; int foo(int i) { static int function (int)[] bar = [ function int(int j){return j+1;}, function int(int j){return j+2;} ]; return bar[i](i); } void main(string[] args) { writeln(foo(1)); }
Comment #1 by bearophile_hugs — 2013-02-23T09:36:02Z
Simpler test case: void main() { static int function(int)[] foo = [x => x]; foo[0](0); }
Comment #2 by yebblies — 2013-11-22T20:47:57Z
Global variables suck! FuncDeclaration::toIR sets cstate.CSpsymtab when doing codegen for main, but then it sets it again when doing the lambda! At the end of the lambda, cstate.CSpsymtab is NULLed, leading to the crash.
Comment #3 by yebblies — 2013-11-22T21:04:25Z
Comment #4 by k.hara.pg — 2013-11-22T22:10:47Z
*** Issue 11264 has been marked as a duplicate of this issue. ***
Comment #5 by github-bugzilla — 2013-11-22T22:16:43Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/3b4a44091209d4a3743579aeb8ca14630a7a2314 Fix Issue 9577 - Crash on static array of function literals https://github.com/D-Programming-Language/dmd/commit/115cf0759e6e44ba01873c501c25cd1c831b209e Merge pull request #2858 from yebblies/issue9577 Issue 9577 - Crash on static array of function literals