Bug 6351 – Regression(2.054) Segfault: Vararg delegate as template param
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-07-19T20:01:00Z
Last change time
2011-08-24T13:40:15Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
bus_dbugzilla
Comments
Comment #0 by bus_dbugzilla — 2011-07-19T20:01:57Z
This crashes the compiler:
void foo(alias dg)()
{
dg();
}
alias foo!( (int[] a...){} ) bar;
Comment #1 by clugdbug — 2011-08-24T04:48:25Z
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 by clugdbug — 2011-08-24T04:50:35Z
*** Issue 6341 has been marked as a duplicate of this issue. ***