www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12710] New: Bad nogc requirement for Windows callbacks

https://issues.dlang.org/show_bug.cgi?id=12710

          Issue ID: 12710
           Summary: Bad  nogc requirement for Windows callbacks
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: thecybershadow gmail.com

////////////////////// test.d /////////////////////
import core.sys.windows.windows;

extern(Windows)
LRESULT wndProc(HWND, UINT, WPARAM, LPARAM) nothrow
{
    return 0;
}

void main()
{
    WNDCLASSW c;
    c.lpfnWndProc = &wndProc;
    RegisterClassW(&c);
}
///////////////////////////////////////////////////

The above no longer compiles. For some reason lpfnWndProc is now required to be
 nogc, which makes no sense, as the callback is called from within the same
thread and is allowed to interact freely with the GC.

A cast is now required, which is not very safe since the cast may subtly allow
an incorrect callback signature or calling convention.

--
May 06 2014