Thread overview
[Issue 6351] New: Regression(2.054) Segfault: Vararg delegate as template param
Jul 20, 2011
Nick Sabalausky
Aug 24, 2011
Don
Aug 24, 2011
Don
Aug 24, 2011
Don
Aug 24, 2011
Walter Bright
July 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6351

           Summary: Regression(2.054) Segfault: Vararg delegate as
                    template param
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: cbkbbejeap@mailinator.com


--- Comment #0 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2011-07-19 20:01:57 PDT ---
This crashes the compiler:

void foo(alias dg)()
{
    dg();
}
alias foo!( (int[] a...){} ) bar;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6351


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-08-24 04:48:25 PDT ---
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;
+    }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6351


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |robert@octarineparrot.com


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-08-24 04:50:35 PDT ---
*** Issue 6341 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6351



--- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-08-24 11:38:14 PDT ---
https://github.com/D-Programming-Language/dmd/pull/330

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6351


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-08-24 13:40:15 PDT ---
https://github.com/D-Programming-Language/dmd/commit/b9ee455e4e8c129b429d8e22fd4f6d15885274fb

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------