D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6351 - Regression(2.054) Segfault: Vararg delegate as template param
Summary: Regression(2.054) Segfault: Vararg delegate as template param
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 regression
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
: 6341 (view as issue list)
Depends on:
Blocks:
 
Reported: 2011-07-19 20:01 UTC by Nick Sabalausky
Modified: 2011-08-24 13:40 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nick Sabalausky 2011-07-19 20:01:57 UTC
This crashes the compiler:

void foo(alias dg)()
{
    dg();
}
alias foo!( (int[] a...){} ) bar;
Comment 1 Don 2011-08-24 04:48:25 UTC
Another test case, involving a variable instead of a delegate literal:

void bug6351(alias dg)()
{
    dg();
}

void delegate(int[] a...) deleg6351 = (int[] a...){};

alias bug6351!(deleg6351) baz6531;

The problem is in expression.c, functionParameters().
The parameter 'fd' is NULL, but the function calls fd->isSafe().
In fact, 'fd' will be null for any kind of call involving a variable -- TOKvar, TOKdotvar, TOKindex, TOKstar, TOKcall, TOKdotti.

For the delegate literal case, we can determine 'fd' in expression.c 7618. This will allow @safe inference for delegate literals as parameters.
For the variable case, the function type should be used instead of fd.

Lcheckargs:
    assert(tf->ty == Tfunction);

+    if (!f && e1->op == TOKfunction)
+    {
+        f = ((FuncExp *)e1)->fd;
+    }
Comment 2 Don 2011-08-24 04:50:35 UTC
*** Issue 6341 has been marked as a duplicate of this issue. ***