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.