Bug 5159 – Segfault(interpret.c): calling a static function pointer variable in CTFE
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-11-03T13:52:00Z
Last change time
2015-06-09T05:10:46Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2010-11-03T13:52:19Z
It's not yet possible to make a test case which should compile without error. But this one segfaults on 2.050.
---
int function() bug5159 = function int() { return 27; };
static assert(bug5159());
---
PATCH: interpret.c, CallExp::interpret(), line 2715.
if (ecall->op == TOKstar)
{ // Calling a function pointer
Expression * pe = ((PtrExp*)ecall)->e1;
if (pe->op == TOKvar) {
VarDeclaration *vd = ((VarExp *)((PtrExp*)ecall)->e1)->var->isVarDeclaration();
if (vd && vd->value && vd->value->op == TOKsymoff)
fd = ((SymOffExp *)vd->value)->var->isFuncDeclaration();
else {
- ecall = vd->value->interpret(istate);
+ ecall = getVarExp(loc, istate, vd);
+ if (ecall == EXP_CANT_INTERPRET)
+ return ecall;
if (ecall->op == TOKsymoff)
fd = ((SymOffExp *)ecall)->var->isFuncDeclaration();
}