D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5159 - Segfault(interpret.c): calling a static function pointer variable in CTFE
Summary: Segfault(interpret.c): calling a static function pointer variable in CTFE
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2010-11-03 13:52 UTC by Don
Modified: 2015-06-09 05:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2010-11-03 13:52:19 UTC
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();
                }
Comment 1 Walter Bright 2010-11-12 00:56:13 UTC
http://www.dsource.org/projects/dmd/changeset/752