www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8496] New: (Regression 2.060) Assignment of function literal to function pointer variable with non-D linkage broken

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8496

           Summary: (Regression 2.060) Assignment of function literal to
                    function pointer variable with non-D linkage broken
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: alex lycus.org



CEST ---
This used to work in 2.059.

alexrp alexrp ~/Projects/tests $ dmd test.d
test.d(8): Error: cannot implicitly convert expression (__lambda1) of type void
function() pure nothrow  safe to extern (C) void function()
alexrp alexrp ~/Projects/tests $ cat test.d
alias extern (C) void function() Func;

void main()
{
    Func f;

    f = ()
    {
    };
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 02 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8496


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|(Regression 2.060)          |Assignment of function
                   |Assignment of function      |literal to function pointer
                   |literal to function pointer |variable with non-D linkage
                   |variable with non-D linkage |broken
                   |broken                      |
           Severity|regression                  |enhancement



This is not a regression.

In 2.059, this was accidentally allowed by the cause same with bug 8397. It's
already fixed in 2.060.
(Therefore, the call of function pointer f might had been broken in 2.059)

And, lambda type inference does not infer function linkage in current
implementation. Then, (){} is always extern(D), and the error is expected.

But, it is reasonable feature. So I change the importance to 'enhancement'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8496




I'd like to update sample code.

alias extern (C) void function() FP;
void main()
{
    FP fp = (){};

    fp = (){};
}

The fp declaration and assignment should infer the lambda's linkage.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8496


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1135

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8496


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED
         AssignedTo|nobody puremagic.com        |k.hara.pg gmail.com



Fixed D2

https://github.com/D-Programming-Language/dmd/commit/a01abef9aafde2b0f155d55af6f1badbfece8920

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